rendered paste body#!/usr/bin/perl -w
$command_to_print_number_of_trout_saved="troutsaved"; # without /
$xchatdir=Xchat::get_info(xchatdir);
Xchat::register('troutsaver','');
Xchat::hook_server('RAW LINE','is_action');
Xchat::hook_command("$command_to_print_number_of_trout_saved",'print');
Xchat::print("troutsaver loaded");
sub is_action {
my ($who,$is_action,$text) = ($_[0][0],$_[0][3],$_[1][4]);
$is_action =~ s/\001//g;
$who =~ s/\!.*$//g;
$who =~ s/://g;
$text =~ s/\001//g;
if ($is_action =~ /^:.{0,1}ACTION$/) {
saver($who,$text);
}
Xchat::EAT_NONE;
}
sub saver { # saver($who,$text), $who = string (typically who used action)
# $text = string (typically text of ACTION)
# if $who is differnt of your nick (and $text contains "slap.*with.*trout"), then a number of saved trout
# increses of 1 and messages is printed to irc
my ($who,$text,$count,$nick)=($_[0],$_[1]);
$nick=Xchat::get_info(nick);
if ($nick ne $who and $text =~ /.*slap.*with.*trout/i and $text !~ /.*b[a4]ck.*[!1i]n.*p[0o]nd/i) {
open (TROUT,"$xchatdir/.troutsaver-dat");
$count=<TROUT>;
open (TROUT,">$xchatdir/.troutsaver-dat");
$count++;
print TROUT "$count";
close (TROUT);
Xchat::commandf("me slaps $who, takes trout and puts it back in the pond. Trouts saved: $count");
}
elsif ($nick ne $who and $text =~ /.*[z5s][!l1][4a]p.*w[!1i][t7]h.*[7t][r2][0Po]u[7t]/i and $text !~ /.*b[a4]ck.*[!1i]n.*p[0o]nd/i) {
open (TROUT,"$xchatdir/.troutsaver-dat");
$count=<TROUT>;
open (TROUT,">$xchatdir/.troutsaver-dat");
$count++;
print TROUT "$count";
close (TROUT);
$who =~ s/[lL]/1/g; $who =~ s/[iI]/!/g; $who =~ s/[rR]/2/g; $who =~ s/[eE]/3/g; $who =~ s/[aA]/4/g;
$who =~ s/[sS]/5/g; $who =~ s/[tT]/7/g; $who =~ s/[bB]/8/g;
Xchat::commandf("me 5l4pz $who, t4k3s tr0u7 'n' pu7s !7 b4cK !n d4 p0nd. 7r0u7z s4v3d: $count");
}
Xchat::EAT_NONE;
}
sub print {
my ($count);
if ( ! -f "$xchatdir/.troutsaver-dat" ) {
Xchat::commandf("say cool!! no trout haven't been abused!");
} else {
open (TROUT,"$xchatdir/.troutsaver-dat");
$count=<TROUT>;chomp $count;
close (TROUT);
if ($count == 1 ) {
Xchat::commandf("me saves $count trout");
} else {
Xchat::commandf("me saves $count trouts");
}
}
}