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

$VERSION = '1.01';
%IRSSI = (
    authors 	=> 'Eric Jansen',
    contact 	=> 'chaos@sorcery.net',
    name 	=> 'whoisfix',
    description => 'Fixes ugly masked-as/hurt line in whois reply on SorceryNet',
    license 	=> 'GPL',
    modules	=> '',
    url		=> 'http://xyrion.org/irssi/',
    changed 	=> 'Sat Mar  1 13:15:10 CET 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();
    }
}

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