Bot:ShWikiBot

From SHellium Wiki
(Redirected from SHwikiBot)
Jump to: navigation, search
Geographylogo.png In other languages: English | Afrikaans | Albanian | Arabic | Brazilian | Bulgarian | Catalan | Chinese | Croatian | Czech | Danish | Dutch | Esperanto | Estonian | Filipino | Finnish | Flemish | French | German | Greek | Hebrew | Hindi | Hungarian | Indonesian | Italian | Japanese | Latvian | Lithuanian | Macedonian | Malay | Malayalam | Norwegian (Bokmål) | Norwegian (Nynorsk) | Persian | Polish | Portuguese | Romanian | Russian | Serbian | Slovak | Slovenian | Spanish | Swedish | Turkish | Ukrainian | Urdu

ShWikiBot reports all edits to the wiki to #shellium.

Contents

LocalSettings.php

Add the following to your local settings file:

// IRC # post: 555666
$wgRC2UDPAddress = '127.0.0.1';
$wgRC2UDPPort = '555666';
$wgRC2UDPPrefix = "";

UDPserver.pl

#!/usr/bin/perl
 
use warnings;
use strict;
 
use POE;
use IO::Socket::INET;
 
use constant DATAGRAM_MAXLEN => 1024;
 
if (!$ARGV[0]) {
  print "Usage: $0 <port>\n";
  exit;
}
 
select((select(STDOUT), $|=1)[0]);
 
POE::Session->create(
    inline_states => {
        _start       => \&server_start,
        get_datagram => \&server_read,
      }
);
 
POE::Kernel->run();
exit;
 
sub server_start {
    my $kernel = $_[KERNEL];
 
    my $socket = IO::Socket::INET->new(
        Proto     => 'udp',
        LocalPort => $ARGV[0],
    );
 
    die "Couldn't create server socket: $!" unless $socket;
    $kernel->select_read( $socket, "get_datagram" );
}
 
sub server_read {
    my ( $kernel, $socket ) = @_[ KERNEL, ARG0 ];
    recv( $socket, my $message = "", DATAGRAM_MAXLEN, 0 );
    print STDOUT "$message";
}

Instead of this Perl script, you can simply use netcat -lup <port> or socat UDP4-LISTEN:<port> STDOUT

Command

Run this command on the receiving computer:

./UDPserver.pl <port> | ircII -d -c \#<channel> <nick> <irc_server>

In the above entries used in your LocalSettings.php file <port> would be 555666.

Instead of ./UDPserver.pl <port>, you can also use netcat -lup <port> or socat UDP4-LISTEN:<port> STDOUT

Requirements

Requires ircii which can be downloaded from eterna.com.au. It can be found in almost all Linux distributions packaged and ready to install.

This Perl script also requires POE, which you may find was not packaged with your system. Not to worry! Very easy to install.

POE may be installed through the CPAN shell which you should find on your system.

  % perl -MCPAN -e shell
  cpan> install POE

When CPAN is first run, it will ask you a series of questions, however the defaults seemed to work fine for me. However I did have a problem with some FTP sites not having the POE file, so I went for ones in the US and they had it.

You may find that POE fails to install with a message that says cannot install unless force is used as a number of tests have failed. You might want to check the seriousness of these errors, however its possible to force via the following syntax.

 cpan> force install POE

Caveats

Currently, anyone can "hack" your bot by sending packets to the port you specify. This can be fixed with iptables.

Personal tools
Namespaces

Variants
Actions
Navigation
Indexes
SHellium Sites
Toolbox