Once upon a time there was a Linux user group which switched it’s chatting system to SILC. Unfortunately there was no Chatbot available for SILC and the user group had to live without. Suddently, in the beginning of ’05, somebody had the time to write a bot, called Megasus, which runs inside the Irssi client, which is used by SILC as well. From now on the chat was enriched by nice information provided by a Bot. But Megasus had a problem, (actually the Irssi client when you call fork() inside of it) and it was leaking memory like hell, until the bad Adminstrators where forced to put memory and runtime limits on the machine. This lead to Megasus dying a horrible death every week and really annoyed the author. But then…

Well, I have been looking for real Perl bindings for the SILC Client API for quite a while. The problem is that there are none. Apparantly, nobody took it’s time to write something which would allow something like:

use Net::SILC::Client;
use Chatbot::Eliza;

my $bot = new Chatbot::Eliza( );

sub on_channel_message {
    my ($self, $channel, $nick, $message) = @_;

    if ($message =~ $self->nickname) {
        my $answer = $bot->transform($message);

                               $nick . ': '  . $answer );

my $silc = Net::SILC::Client->new (channels => [ 'silc' ],
                                   nickname => 'NSC');

$silc->set_callback('channel_message', &on_channel_message);


A few days ago, I stumbled over a Sourceforge Project which attempted to create a Perl wrapper for the SILC API. They hadn’t released any code and as the project was founded in 2002 I contacted the authors and asked if they had already done some work, because I started believing that I would have to do this myself. They where really friendly and they had code, but only wrapping some of SILCs Math functions and not really what I needed. So I started writing from scratch.

As of today, you can run the above example and it does what it has to, plus there are a couple of other events that you can handle directly from Perl. As this is my first Perl/C/PerlXS Module I believe that it is leaking memory like hell as well as there are a couple of other problems (vanishing scalars between two function calls is one of them). But it supports all important events (you can set callbacks as this whole system is event driven), lets you issue commands and send private and channel messages. What I need to do to make it a possible frontend for Megasus is that I need an other Event System (for things like fetching RSS feeds) and some other minor fixes, but the major part is done. The Event System is a little bit tricky, as I tried to use and running the SILC Main Loop with it which crashed horibly and I’m still not really good in debugging this stuff. And of course, it is lacking documentation (there are two examples which show the main methods as well as some information about the events, but this is not really good). It’s still far away from something I’d release to the CPAN, but If you want to have a look, it’s all in the CVS on Sourceforge.