]> jfr.im git - irc/evilnet/x3.git/blame - tools/mrsnoopy.pl
Fix for bug in X3.unban handling
[irc/evilnet/x3.git] / tools / mrsnoopy.pl
CommitLineData
3905cc2c 1#!/usr/bin/perl -w
2
3# Author: rubin@afternet.org irc.afternet.org/#afternet
4
fe896bf8 5$script_version = "0.3";
3905cc2c 6$script_name = "MrSnoopy's magic color kit v$script_version";
7$version = IRC::get_info(0);
8# get a string of the form 1.2.0 or 1.3.3
9$version =~ s/\.//g;
10if ($version >= 120) {
11 IRC::register("MrSnoopy's magic color kit", $script_version, "", "");
12}
13
14IRC::add_message_handler("PRIVMSG", "IRC::Xchat::MrSnoopy::privmsg_handler"); # msgs
15
16package IRC::Xchat::MrSnoopy;
17
18IRC::print "\0032SNOOPY: \003\tLoading $script_name...\n";
19
20$color_darkgreen = '03';
21$color_darkblue = '02';
22$color_white = '00';
23$color_black = '01';
24$color_red = '04';
25$color_darkred = '05';
26$color_darkmajenta = '06';
27$color_darkyellow = '07';
28$color_yellow = '08';
29$color_green = '09';
30$color_darkcyan = '10';
31$color_cyan = '11';
32$color_blue = '12';
33$color_majenta = '13';
34$color_darkgrey = '14';
35$color_grey = '15';
36
37$dronename_file = $ENV{'HOME'}."/.xchat2/drones.txt";
38
39# Load pendrone names
40#----------------------
41my %DroneNames;
42my $line = "";
43open PENFILE, "<$dronename_file" or IRC::print "\0032SNOOPY: \003\t Error opening $dronename_file\n";
44while(<PENFILE>)
45{
46 chomp;
47 $line .= $_;
48}
49@lines = split /\n/, $line;
50foreach $line (@lines)
51{
52 $DroneNames{"$line"} = 1;
53# IRC::print "Adding penDrone name '$line'\n";
54}
55#----------------------
56$count = 0 + %DroneNames;
57IRC::print "\0032SNOOPY: \003\t Added $count names from drone file $dronename_file\n";
58
59sub privmsg_handler
60{
61 local($cmds) = @_;
62 $cmds =~ /\:(\S+)\s+PRIVMSG\s+(\S+)\s+\:(.*)/;
63 $source = $1;
64 $target = $2;
65 $msg = $3;
66
67 if($target =~ /\#MrSnoopy/)
68 {
69 $source =~ /(\S+)\!(\S+)\@(\S+)/;
70 $snick = $1;
71 $suname = $2;
72 $shost = $3;
73
74 # [15:14:10] QUIT efggv (KIM666@82-35-112-226.cable.ubr07.dals.blueyonder.co.uk, on Gamesleague.NL.Afternet.Org) (Quit)
75 if($msg =~ /(\[[^]]+\])\W+(\w+)\W+ (.+)/)
76 {
77 $time = $1;
78 $note_type = $2;
79 $message = $3;
80
fe896bf8 81 if($note_type =~ /(JOIN)/)
3905cc2c 82 {
3905cc2c 83 $message =~ /(\S+)\sby\s(\S+)/;
84 $chan = $1;
85 $nick = $2;
fe896bf8 86 IRC::print "$time \003".$color_darkyellow." JOIN\t$nick joined \003$color_darkyellow$chan\003\n";
3905cc2c 87 }
fe896bf8 88 elsif($note_type =~ /(CREATE)/)
3905cc2c 89 {
90 $message =~ /(\S+)\sby\s(\S+)/;
91 $chan = $1;
92 $nick = $2;
fe896bf8 93 IRC::print "$time \003".$color_darkyellow." CREATE\t$nick joined $chan\003\n";
94 }
95 elsif($note_type =~ /PART/)
96 {
97 $message =~ /(\S+)\sby\s(\S+)/;
98 $chan = $1;
99 $nick = $2;
100 IRC::print "$time \003".$color_darkmajenta." PART\t$nick left $chan\003\n";
3905cc2c 101 }
102 elsif($note_type =~ /NICK/)
103 {
104 # Armagedon|RoA-afk Armagedon_@c56-151.icpnet.pl () [62.21.56.151] on Airspace.US.AfterNET.Org
105 if($message =~ /(\S+)\s([^@]+)\@(\S+)\s\(([^)]*)\)\s\[([^]]+)\]\son\s(\S+)/)
106 {
107 $nick = sprintf("%-15s", $1);
fe896bf8 108 #$user = sprintf("%10s", $2);
109 $user = $2;
3905cc2c 110 $host = $3;
111 $account = $4;
112 $ip = sprintf("%15s", $5);
113 $server = $6;
fe896bf8 114 #IRC::print "$time \003".$color_green."CONNECT\t[\003$color_blue$ip\003$color_green] as $nick \003$color_darkcyan$user\003$color_grey@\003$color_darkcyan$host \003$color_green(\003$color_yellow$account\003$color_green) on $server\n";
115 IRC::print "$time \003".$color_green."CONNECT\t$nick (\003$color_darkcyan$user\003$color_grey@\003$color_darkcyan$host\003$color_green) \003$color_yellow*$account\003$color_green [\003$color_blue$ip\003$color_green] on $server\003\n";
3905cc2c 116 #if(exists $DroneNames{$1})
117 if(exists $DroneNames{$1} && exists $DroneNames{$2} && !($1 eq $2))
118 {
119 IRC::print "\0032SNOOPY: \003\t$time \003".$color_red."!!!!! '$1' is a drone!\n";
120 IRC::command "/MSG #Operations .drone $1 AUTO";
121 }
122 #else
123 #{
124 #IRC::print "\003".$color_green." \t '$1' Not a drone\n";
125 #}
126 }
fe896bf8 127 #[21:32:45] NICK change Lil_JJ -> [-BDC-]J_Word
128 elsif($message =~ /change (\S+)\s\-\>\s(\S+)/)
129 {
130 $old = $1;
131 $new = $2;
132 IRC::print "$time \003".$color_darkgreen." NICK\t$old is now known as $new\003\n";
133 return 1;
134 }
3905cc2c 135 else
136 {
137 return 0;
138 }
139 }
140 elsif($note_type =~ /QUIT/)
141 {
142 # InvaderC1 (Chadwick@adsl-67-125-1-144.dsl.scrm01.pacbell.net, on Gamesleague.NL.Afternet.Org) (Ping timeout)
fe896bf8 143 #OR - QUIT Nader (supybot@CPE-72-131-73-97.mn.res.rr.com, on Pyro.US.AfterNET.Org) (Killed (Rubin (testing snoop)))
144 #OR - no "killed" at all? WTF is up with snoop and kills.
145 $message =~ /(\S+)\s\(([^@]+)\@([^,]+)\,\son\s(\S+)\)\s\((Killed|)(.+)\)/;
146 $nick = sprintf("%-15s", $1);
3905cc2c 147 $user = $2;
148 $host = $3;
149 $server = $4;
fe896bf8 150 $killed = $5;
151 $quitmsg = $6;
152 IRC::print "$time \003".$color_darkred." QUIT\t$nick (\003$color_darkgrey$user\003$color_grey@\003$color_darkgrey$host\003$color_darkred) on $server (\003$color_white$quitmsg\003$color_darkred)\003 [$killed]\n";
153 #return 0; # debug
3905cc2c 154 }
fe896bf8 155 elsif($note_type=~/UMODE/)
156 {
157 #Walter +rx Walter
158 if($message =~ /(\S+)\s+(.+)\s*(\S*)/)
159 {
160 $nick = $1;
161 $mode = $2;
162
163 IRC::print "$time \003".$color_darkgrey." UMODE\t$nick \002$mode\002 $nick\003\n";
164 }
165 else
166 {
167 return 0;
168 }
169 }
3905cc2c 170 elsif($note_type =~/MODE/)
171 {
172 # afternet +l 12 by X3
fe896bf8 173 if($message =~ /\s*(\S+)\s+(.+)\sby\s(\S+)/)
174 {
175 $channel = $1;
176 $mode = $2;
177 $nick = $3;
178 IRC::print "$time \003$color_grey MODE\t$nick set \002$mode\002 on $channel\003\n";
179 }
180 else
181 {
182 return 0;
183 }
184 }
185 elsif($note_type =~ /AUTH/)
186 {
187 #teclis as cehb
188 $message =~ /(\S+)\sas\s(\S+)/;
189 $nick = $1;
190 $account = $2;
191 IRC::print "$time \003$color_darkgreen AUTH\t$nick as \003$color_yellow*$account\003\n";
192 }
193 elsif($note_type =~ /KILL/)
194 {
195 #Sore (mem0ry@Toronto-HSE-ppp3667456.sympatico.ca, on Pyro.US.AfterNET.Org) by AuthServ (Ghost kill on account Sorea (requested by Eros).)
196 if($message =~ /(\S+)\s\(([^@]+)\@([^,]+)\,\son\s(\S+)\)\sby\s(\S+)\s(.*)\)/)
197 {
198 $nick = $1;
199 $user = $2;
200 $host = $3;
201 $server = $4;
202 $killer = $5;
203 $message = $6;
204 IRC::print "$time \003".$color_darkred." KILL\t$nick (\003$color_darkgrey$user\003$color_grey@\003$color_darkgrey$host\003$color_darkred) on $server by $killer (\003$color_white$quitmsg\003$color_darkred)\003\n";
205
206 }
207 else
208 {
209 return 0;
210 }
3905cc2c 211 }
212 else
213 {
fe896bf8 214 #didnt understand it, just let xchat print it
3905cc2c 215 return 0;
216 }
217 # Successfully handled it, return handled
218 return 1;
219 }
220 else
221 {
222 #IRC::print "'$msg' didnt match\n";
223 return 0;
224 }
225 }
226
227 return 0;
228}
229IRC::print "\0032SNOOPY: \003\t...Done\n";
2301;
231_END_
232