Just a quick update today – been spending some time writing a little Jabber bot.

It’s also my first real excursion into local::lib – initially, I wasn’t sure about pulling down CPAN packages, but the package I wanted to use to write bot wanted some fresh stuff. Rather than risk breaking other parts of the system by installing packages into the system lib directories, local::lib lets me keep whatever I need “local” to the project.

Debian doesn’t (yet) ship local::lib as a package in its stable repo, but the package for squeeze installs cleanly. This Work For Me™, as it’s installed system-wide and when the new release is made I know I’ll get any updates.

So, local::lib installed, I grabbed the Net::Jabber::Bot package from CPAN. For some reason, the CPAN install run failed a load of tests, but when I re-ran it, it pulled down some more packages and worked. So it goes…

The documentation for Net::Jabber::Bot is…not that great (yes, yes, I know – submit a patch). The HTML version on CPAN has formatting issues with example code, but the POD version is fine.

The Jabber server I was going to post to uses the Google servers for connection, and runs as a separate conference server, so my initial problem was connecting to the Google server. It would connect, but fail to authenticate, and not return any error messages.

A bit of searching different mailing lists, and I’d found the culprit – authenticating to the Google servers requires version 1.23 of the XML::Stream package, and I’d only got version 1.22 installed. XML::Stream is a dependency of Net::XMPP (which is a dependency of Net::Jabber, which is a understandably a dependency of Net::Jabber::Bot), and although that particular version is not required per-se, I personally think it might be a good idea for Net::Jabber::Bot to specifically require that version (or later) of that package – it should harm no other Jabber server, and would prevent other people having to follow exactly the investigation I did.

More local::lib-fu, and I was in!

For the record, my Net::Jabber::Bot object was created like this:

my $bot = Net::Jabber::Bot->new( {
 server => 'talk.google.com',
 server_host => 'gmail.com',
 tls => 1,
 conference_server => $conf_server,
 username => $username,
 password => $password,
 alias => $alias,
 message_function => \&new_bot_message,
 forums_and_responses => \%f_and_r,
} );

I pulled some more code from the example bot, created a simple learn/forget/is system (backed by an SQLite database), and my bot is up and running (and learning all kinds of junk as I haven’t put in any kind of access control yet). I’m still having problems getting it to send direct messages, but as a general announce bot it’s working well.