Recent Events for foo.be MainPageDiary (Blog) Previous Next

2006-11-12 Djabberd The Versatile Jabber Server

Upgrading a Jabber server... and discovering a nice XMPP framework

Beside a lot of stuff to do for my daily and nightly work, I made a small and interesting discovery in the area of XMPP server. I planned to upgrade an old (and worst… unstable and unsecure) Jabber server. Finding the right XMPP server is not easy but I found the one created from scratch by Brad Fitzpatrick called djabberd. It's a very flexible XMPP framework written in (clean) Perl where everything is a plugin and supporting the XMPP standard quite well. If you are interested in my minimal configuration, just have a look (I'm using the standard Digest HTTP authentication but you are free to use the authentication approach that fits your needs). When digging in its operation, I found that modularity is real. I wrote a very small plugin in 2 minutes to query Wikipedia :

package DJabberd::Bot::Wikipedia;
use strict;
use warnings;
use base 'DJabberd::Bot';
use WWW::Wikipedia;
use DJabberd::Util qw(exml);

our $logger = DJabberd::Log->get_logger();

sub finalize {
    my ($self) = @_;
    $self->{nodename} ||= "wikipedia";
    $self->{bot} = WWW::Wikipedia->new;
    $self->SUPER::finalize();
}

sub process_text {
    my ($self, $text, $from, $cb) = @_;
    my $entry = $self->{bot}->search($text);
    if ($entry)  {
            $cb->reply($entry->text());
    } else {
            $cb->reply("Entry not existing in Wikipedia.");
    }
}

1;

If you want to test it, just send a Jabber/XMPP message to wikipedia@a.6f2.net with a word. Nifty and Easy…

Infobot back in Jabber ?

Playing with that, I remembered the discussion with Vincent about the Infobot running on the IRC where you can ask for "factoid" and get a result. Wikipedia is full of "factoid" (in the good sense), I mean of sentence structured like "X is Y" and full of karma (X++ when is a recurring sentence ). So why not building a database of factoid from Wikipedia ? That could be useful for building pseudo-AI bot in instant messaging. Imagine a chat room in Jabber where the bot is playing is role when a large discussion is taking place and some clarification is required on a term. It's really funny we are going back to a more textual society with such new tools… (IRC is not dead ?). So a quite good news.