autocorrect irssi script

autocorrect is a script I wrote to autocorrect common typos of mine, but also to eliminate umlaut-centric problems while conversating on irc. In a nutshell, it simply replaces ü, ä, ö and ß with ue, ae, oe and ss, and replaces :Ü with :P (what is what I always intend to type when I put out this character combo ;) ). Those replacements only happen when one is typing in a channel or a query, not in the commandwindow.

autocorrect.pl

use strict;
 
use vars qw($VERSION %IRSSI);
$VERSION = "20040901";
%IRSSI = (
    authors     => "Gina 'foosel' Haeussge",
    contact     => "www[at]foosel[dot]net",
    name        => "autocorrect",
    description => "Corrects common typos and replaces umlauts with their common equivalent",
    license     => "GPLv2",
    changed     => "$VERSION"
);
 
use Irssi 20020324;
 
# replacement function
sub autocorrectme ($$$) {
    my ($text, $server, $witem) = @_;
    # only autocorrect me when I'm talking in a channel or a query
    if ($witem && ($witem->{type} eq 'CHANNEL' ||
            $witem->{type} eq 'QUERY')) {
        $text =~ s/:Ü/:P/g;
        $text =~ s/:ü/:p/g;
        $text =~ s/ü/ue/g;
        $text =~ s/ä/ae/g;
        $text =~ s/ö/oe/g;
        $text =~ s/ß/ss/g;
        $text =~ s/Ü/Ue/g;
        $text =~ s/Ä/Ae/g;
        $text =~ s/Ö/Oe/g;
        Irssi::signal_continue($text, $server, $witem);
    # else just put out what was put in
    } else {
        Irssi::signal_continue($text, $server, $witem);
    }
}
 
# automatically invoke the autocorrect routine 
# if a text is about to be sent
Irssi::signal_add('send text', 'autocorrectme');
 
# print load message
print "%B>>%n ".$IRSSI{name}."
        ".$VERSION." loaded";

Download the script.