I recently changed IRC clients from XChat to irssi. The change was mainly motivated by the ability to run irssi in screen, which graphical clients can't do.

Since irssi doesn't run exactly as I want it to, I have learned enough perl to script the behaviour I want. (That means I know perl well enough to write it, but not to read it.) There are two scripts so far. One of them is nothing more than a collection of convenient command bindings and not really of very much use to anyone else. The other is included below.

use strict;
use vars qw($VERSION %IRSSI);
use Irssi qw(signal_add signal_emit settings_add_str settings_get_str
            settings_add_bool settings_get_bool);

$VERSION = '0.10';
%IRSSI = (
    authors     => 'Jerith',
    contact     => 'jerith@nightstar.net',
    name        => 'beepchan',
    description => 'Sends a beep signal when messages are received on '.
                    'selected channels.',
    license     => 'Public Domain',
);

sub beepchan {
    my ($server, $msg, $nick, $address, $target) = @_;

    return if not settings_get_bool('beep_on_channel');
    my $channels = settings_get_str('beep_channels');
    $channels =~ tr/ /|/;
    signal_emit('beep') if $target =~ /$channels/i;
}

sub beephilight {
    my ($dest, $text, $stripped) = @_;

    return if not settings_get_bool('beep_on_hilight');

    signal_emit('beep') if (($dest->{level} & (MSGLEVEL_HILIGHT|MSGLEVEL_MSGS))
                                && ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0);
}

signal_add('message public', 'beepchan');
signal_add('message irc action', 'beepchan');
signal_add('print text', 'beephilight');
settings_add_bool('misc', 'beep_on_channel', 1);
settings_add_bool('misc', 'beep_on_hilight', 1);
settings_add_str('misc','beep_channels','#foo #bar #baz');

Basically, this takes a list of channels and sends a beep signal whenever a channel with that name shows activity. It also beeps whenever a message is highlighted. This is particularly useful if irssi is hidden (behind another window, on another workspace, minimised, whatever) and you don't want to miss anything important.

Note to self, and anyone else writing irssi scripts that bind to the "print text" signal: an error in a script that is triggered on (amongst other things) error messages is a Bad Idea.