Manual:IRC RC Bot

To create a simple IRC bot to display recent changes to your Wiki:

LocalSettings.php
Add the following to your local settings file:

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

UDPserver.pl

 * 1) !/usr/bin/perl

use warnings; use strict;

use POE; use IO::Socket::INET;

use constant DATAGRAM_MAXLEN => 1024;

if (!$ARGV[0]) { print "Usage: $0 \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"; }

Command
Run this command on the receiving computer:

./UDPserver.pl | irc-20040820 -d -c \# 

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

Requirements
Requires ircii which can be downloaded from here eterna.com.au

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.

However, in the long run, a more complex bot should be written to allow for restrictions and perhaps some more stuff.