Having an artificial intelligence in your channel is sometimes fun, so here's a way of integrating MegaHAL with Irssi for fun and games. It uses four major components.

First, you'll need the MegaHAL Perl module installing. Grab the megahal-9.1.1 source and untar it. Change to megahal-9.1.1/Megahal (the Perl module directory), build it and install it using the Makefiles provided. That's the only part of the MegaHAL distribution you'll need.

Second of all, download and untar the latest AI::Megahal from CPAN(0.07 at time of writing). This version already includes the 0.06 patch (available here for the curious) I released that enables learning without generating a response. Proceed to build the module in the normal manner with Makefile.PL.

Finally, download MegaHAL_Irssi-2.0.tgz, untar it, and put it into your irssi scripts directory. Just load it like any other script and you should get a whole bunch of new, exciting configuration options. In summary, they are:

  • megahal_brain - The directory containing the megahal.brn or megahal.trn file
  • megahal_channels - A list of valid channels or targets to listen in, e.g. #megahal
  • megahal_antiflood - Prevent a user spamming the bot with requests. See the next two options:
  • megahal_flood_ratio - A string in the format X:Y, where X is the number of lines and Y is the number of seconds before ignoring somebody. For example, 10:60 means that if somebody says 10 things to the bot in 60 seconds they will be ignored
  • megahal_ignore_timeout - The number of seconds to ignore a user if they spam the bot

Set them as normal Irssi settings using /set.

In addition, there is a silly little poetical addition. In any channel listed in megahal_channels, type:

    !haiku <keywords>

The keywords can be anything you like. The bot will write a simple and badly formatted haiku about your chosen subject. Completely pointless, but occasionally hilarious!

I'm using Perl 5.8.8 and

I'm using Perl 5.8.8 and compiled everything today. I had to add two 'use lib' lines because my Perl directory is not in my @INC and because I installed Perl from Mac Ports to override the included Perl dist. I have one 'use lib' line '/opt/local/lib/perl5/site_perl/5.8.8/' and another '/opt/local/lib/perl5/site_perl/5.8.8/POE/Component/'. The script loads without complaints when I use those lines and has errors if I do anything differently. The segfault doesn't happen until I /set megahal_brain. Other perl scripts work fine with Irssi.

Thanks for your help thus far!

megahal 9.1.1

Setting the megahal_brain value is the first time the AI::MegaHAL class is instantiated, so that's why it all kicks off at that point. The only time I've seen this is when there is a Perl version mismatch between megahal-9.1.1, AI::MegaHAL-0.07 and Irssi. I'll check it out with 5.8.8 and see if there are any problems. What C compiler are you using? The version of gcc shipped with Xcode or the version from macports?


Hah hah... don't laugh: make

Hah hah... don't laugh: make from Fink ports actually. I know I should have stuck with one ports repository.

GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A

This program built for i386-apple-darwin9.1.0

Fair enough :) I'll try

Fair enough :) I'll try installing it on OS X using the built-in Perl version first, to make sure there are no problems with the platform. Just one more question: Is Irssi using a built-in perl interpreter, or is it configured to use the macports one?


Irssi embeds its own

Irssi embeds its own interpreter. Maybe that is the problem!

Hmm... could this be the

Hmm... could this be the problem? "AI::MegaHAL is up to date (0.07)". Your README says to use AI::Megahal 0.06_0


The README is a bit unclear. It should say to use 0.07 as it includes a patch I wrote for 0.06. I will update the README now to make it clearer.