use Irssi;
use strict;
use vars qw($VERSION %IRSSI);

$VERSION = '1.02';
%IRSSI = (
    authors 	=> 'Eric Jansen',
    contact 	=> 'chaos@sorcery.net',
    name 	=> 'whoisfix',
    description => 'Fixes layout of whois reply on SorceryNet',
    commands	=> '',
    license 	=> 'GPL',
    modules	=> '',
    url		=> 'http://xyrion.org/irssi/',
    changed 	=> 'Thu Jun 19 15:01:13 CEST 2003'
);

sub event_whois {

    my ($server, $data, $nick, $host) = @_;

    if($data =~ /^\S+ (\S+) :is masked as (\S+)$/) {

	$server->printformat($1, MSGLEVEL_CRAP, 'whois_masked', $2);
	Irssi::signal_stop();
    }

    elsif($data =~ /^\S+ (\S+) :has been muted$/) {

	$server->printformat($1, MSGLEVEL_CRAP, 'whois_muted', $2);
	Irssi::signal_stop();
    }

    elsif($data =~ /^\S+ (\S+) :is using (.+)$/) {

	$server->printformat($1, MSGLEVEL_CRAP, 'whois_version', $2);
	Irssi::signal_stop();
    }
}

Irssi::theme_register([
    'whois_masked', '{whois  %|masked as $0}',
    'whois_muted', '{whois  %|has been muted}',
    'whois_version', '{whois version %|$0'
]);
Irssi::signal_add('event 309', 'event_whois');
Irssi::signal_add('event 550', 'event_whois');
Irssi::signal_add('event 551', 'event_whois');
