diff options
| author | 2012-08-21 07:49:29 +0000 | |
|---|---|---|
| committer | 2012-08-21 07:49:29 +0000 | |
| commit | 566c36647cb05d58c97af14db1e37df0b54bcf2c (patch) | |
| tree | b8c654558a984ef575839f6b0fecc6213454fb9d | |
| parent | 4fb036a66821ef4749dfdb3ebc598ef21e2e4502 (diff) | |
stats p tracking, better pingpong stuff, added an XML setting for a master chan rather than having one hardcoded, state tracking for channel URL
| -rw-r--r-- | config-default/channels.xml | 2 | ||||
| -rw-r--r-- | config-default/settings.xml | 2 | ||||
| -rw-r--r-- | config-default/users.xml | 3 | ||||
| -rwxr-xr-x | meta.pl | 8 | ||||
| -rw-r--r-- | modules/event.pl | 79 | ||||
| -rw-r--r-- | modules/services.pl | 3 | ||||
| -rw-r--r-- | modules/xml.pl | 7 |
7 files changed, 81 insertions, 23 deletions
diff --git a/config-default/channels.xml b/config-default/channels.xml index ecefc7a..178a0bb 100644 --- a/config-default/channels.xml +++ b/config-default/channels.xml @@ -139,6 +139,7 @@ <msgs></msgs> </channel> <channel id="#antispammeta-debug" /> + <channel id="#baadf00d" /> <channel id="#cisco"> <hilights></hilights> <msgs></msgs> @@ -701,6 +702,7 @@ <debug>#wikimedia-ops</debug> </msgs> </channel> + <channel id="antispammetabeta" /> <channel id="default"> <hilights></hilights> </channel> diff --git a/config-default/settings.xml b/config-default/settings.xml index cb9e554..66eab42 100644 --- a/config-default/settings.xml +++ b/config-default/settings.xml @@ -34,4 +34,6 @@ </server> <username>MetaBot</username> <lookupexpire>2419200</lookupexpire> + <masterchan>#antispammeta</masterchan> + <debugchan>#antispammeta-debug</debugchan> </settings> diff --git a/config-default/users.xml b/config-default/users.xml index c01a206..7902bcc 100644 --- a/config-default/users.xml +++ b/config-default/users.xml @@ -10,7 +10,7 @@ <person id="errantego" flags="doath" /> <person id="gary" flags="oath" /> <person id="idleone" flags="o" /> - <person id="jeremyb" flags="th" /> + <person id="jeremyb" flags="oth" /> <person id="jonathand" flags="oath" /> <person id="kelsie" flags="a" /> <person id="kindone" flags="t" /> @@ -18,6 +18,7 @@ <person id="logan_" flags="oath" /> <person id="lstarnes" flags="oath" /> <person id="marienz" flags="doath" /> + <person id="mrmist" flags="doath" /> <person id="martinp23" flags="oath" /> <person id="mquin" flags="hota" /> <person id="myrtti" flags="htoa" /> @@ -26,7 +26,7 @@ $::cset = ''; ## debug variables. 0 to turn off debugging, else set it to a Term::ANSIColor constant. %::debugx = ( "dnsbl" => 0, - "pingpong" => 0, + "pingpong" => 0, #BLUE, "services" => YELLOW, "sync" => CYAN, "chanstate" => MAGENTA, @@ -37,7 +37,9 @@ $::cset = ''; "commander" => GREEN, "msg" => GREEN, "dcc" => RED, - "misc" => RED + "misc" => 0, #RED + "latency" => RED, + "statsp" => 0 #MAGENTA ); %::dsock = (); %::spy = (); @@ -85,7 +87,7 @@ sub init { $::inspector = ASM::Inspect->new(); $::services = ASM::Services->new(); $::commander = ASM::Commander->new(); - $::event = ASM::Event->new($conn, $::inspector); + ASM::Event->new($conn, $::inspector); $::classes = ASM::Classes->new(); my @eline=io('exempt.txt')->getlines; chomp @eline; diff --git a/modules/event.pl b/modules/event.pl index 1a2ab14..3ed711c 100644 --- a/modules/event.pl +++ b/modules/event.pl @@ -73,17 +73,60 @@ sub new $conn->add_handler('channelmodeis', \&on_channelmodeis); $conn->add_handler('quietlist', \&on_quietlist); $conn->add_handler('pong', \&on_pong); + $conn->add_handler('statsdebug', \&on_statsdebug); + $conn->add_handler('endofstats', \&on_endofstats); + $conn->add_handler('channelurlis', \&on_channelurlis); bless($self); return $self; } +my $clearstatsp = 1; +my %statsp = (); + +sub on_statsdebug +{ + my ($conn, $event) = @_; + my ($char, $line) = ($event->{args}->[1], $event->{args}->[2]); + if ($char eq 'p') { + if ($line =~ /^(\d+) staff members$/) { + #this is the end of the report + } else { + my ($nick, $userhost) = split(" ", $line); + $userhost =~ s/\((.*)\)/$1/; + my ($user, $host) = split("@", $userhost); + if ($clearstatsp) { + $clearstatsp = 0; + %statsp = (); + } + $statsp{$nick}= [$user, $host]; + } + } +} + +sub on_endofstats +{ + my ($conn, $event) = @_; + if ($event->{args}->[1] eq 'p') { + $clearstatsp=1; + my $tmp = Dumper(\%statsp); chomp $tmp; + ASM::Util->dprint($tmp, 'statsp'); + # $event->{args}->[2] == "End of /STATS report" + #end of /stats p + } +} + sub on_pong { my ($conn, $event) = @_; - alarm 60; - $conn->schedule( 30, sub { $conn->sl("PING :" . time); } ); - ASM::Util->dprint('Ping? Pong!', 'pingpong'); - ASM::Util->dprint(Dumper($event), 'pingpong'); + alarm 90; + $conn->schedule( 60, sub { $conn->sl("PING :" . time); } ); + ASM::Util->dprint('Pong? ... Ping!', 'pingpong'); +# ASM::Util->dprint(Dumper($event), 'pingpong'); + $conn->sl("STATS p"); + my $lag = time - $event->{args}->[0]; + if ($lag > 1) { + ASM::Util->dprint("Latency: $lag", 'latency'); + } } sub on_dchat @@ -117,9 +160,9 @@ sub on_ping { my ($conn, $event) = @_; $conn->sl("PONG " . $event->{args}->[0]); - alarm 200; - ASM::Util->dprint('Ping! Pong?', 'pingpong'); - ASM::Util->dprint(Dumper($event), 'pingpong'); +# alarm 200; + ASM::Util->dprint('Ping? Pong!', 'pingpong'); +# ASM::Util->dprint(Dumper($event), 'pingpong'); } sub on_account @@ -130,7 +173,7 @@ sub on_account sub on_connect { my ($conn, $event) = @_; # need to check for no services - $conn->sl('MODE AntiSpamMeta +Q'); + $conn->sl("MODE $event->{args}->[0] +Q"); if (lc $event->{args}->[0] ne lc $::settings->{nick}) { ASM::Util->dprint('Attempting to regain my main nick', 'startup'); $conn->privmsg( 'NickServ', "regain $::settings->{nick} $::settings->{pass}" ); @@ -143,7 +186,7 @@ sub on_join { my $nick = lc $event->{nick}; my $chan = lc $event->{to}->[0]; my $rate; - alarm 200; +# alarm 200; if ( lc $conn->{_nick} eq lc $nick) { $::sc{$chan} = {}; mkdir($::settings->{log}->{dir} . $chan); @@ -214,14 +257,14 @@ sub on_msg $::commander->command($conn, $event); ASM::Util->dprint($event->{from} . " - " . $event->{args}->[0], 'msg'); if (ASM::Util->notRestricted($event->{nick}, "nomsgs")) { - $conn->privmsg('#antispammeta', $event->{from} . ' told me: ' . $event->{args}->[0]); + $conn->privmsg($::settings->{masterchan}, $event->{from} . ' told me: ' . $event->{args}->[0]); } } sub on_public { my ($conn, $event) = @_; - alarm 200; +# alarm 200; $::inspector->inspect( $conn, $event ); $::log->logg( $event ); $::db->logg( $event ); @@ -264,9 +307,9 @@ sub on_quit $event->{to} = \@channels; $::db->logg( $event ); if (($::netsplit == 0) && ($event->{args}->[0] eq "*.net *.split") && (lc $event->{nick} ne 'chanserv')) { #special, netsplit situation - $conn->privmsg("#antispammeta", "Entering netsplit mode - JOIN and QUIT inspection will be disabled for 60 minutes"); + $conn->privmsg($::settings->{masterchan}, "Entering netsplit mode - JOIN and QUIT inspection will be disabled for 60 minutes"); $::netsplit = 1; - $conn->schedule(60*60, sub { $::netsplit = 0; $conn->privmsg('#antispammeta', 'Returning to regular operation'); }); + $conn->schedule(60*60, sub { $::netsplit = 0; $conn->privmsg($::settings->{masterchan}, 'Returning to regular operation'); }); } $::inspector->inspect( $conn, $event ) unless $::netsplit; $::log->logg( $event ); @@ -500,6 +543,12 @@ sub on_quietlist $::sc{lc $chan}{quiets}{$ban} = { bannedBy => $banner, bannedOn => $bantime }; } +sub on_channelurlis +{ + my ($conn, $event) = @_; + $::sc{lc $event->{args}->[1]}{url} = $event->{args}->[2]; +} + sub on_ctcp { my ($conn, $event) = @_; @@ -564,7 +613,7 @@ sub on_whoxover my $size = `ps -p $$ h -o size`; my $cputime = `ps -p $$ h -o time`; chomp $size; chomp $cputime; - $conn->privmsg("#antispammeta", "Finished syncing after " . (time - $::starttime) . " seconds. " . + $conn->privmsg($::settings->{masterchan}, "Finished syncing after " . (time - $::starttime) . " seconds. " . "I'm tracking " . (scalar (keys %::sn)) . " nicks" . " across " . (scalar (keys %::sc)) . " tracked channels." . " I'm using " . $size . "KB of RAM" . @@ -573,7 +622,7 @@ sub on_whoxover foreach my $c (@{$::settings->{autojoins}}) { $x{$c} = 1; } foreach my $cx (keys %::sc) { delete $x{$cx}; } if (scalar (keys %x)) { - $conn->privmsg("#antispammeta", "Syncing appears to have failed for " . ASM::Util->commaAndify(keys %x)); + $conn->privmsg($::settings->{masterchan}, "Syncing appears to have failed for " . ASM::Util->commaAndify(keys %x)); } } } diff --git a/modules/services.pl b/modules/services.pl index 2950253..4783d2b 100644 --- a/modules/services.pl +++ b/modules/services.pl @@ -36,7 +36,8 @@ sub doServices { } else { $conn->join(join(',', @autojoins)); } - $conn->schedule(2, sub { $conn->privmsg('#antispammeta', 'Now joined to all channels in '. (time - $::starttime) . " seconds."); }); + $conn->sl("PING :" . time); + $conn->schedule(2, sub { $conn->privmsg($::settings->{masterchan}, 'Now joined to all channels in '. (time - $::starttime) . " seconds."); }); } elsif ($event->{args}->[0] =~ /has been (killed|released)/ ) { diff --git a/modules/xml.pl b/modules/xml.pl index a23df77..e9b96aa 100644 --- a/modules/xml.pl +++ b/modules/xml.pl @@ -23,9 +23,10 @@ sub readXML { sub writeXML { $::xs1->XMLout($::settings, RootName => 'settings', KeyAttr => ['id'], GroupTags => { altnicks => 'altnick', server => 'host', autojoins => 'autojoin' }, - ValueAttr => { debug => 'content', nick => 'content', port => 'content', - realname => 'content', username => 'content', dir => 'content', - zone => 'content', filefmt => 'content', timefmt => 'content'}) > io("$::cset/settings.xml"); + ValueAttr => { debug => 'content', nick => 'content', port => 'content', + realname => 'content', username => 'content', dir => 'content', + zone => 'content', filefmt => 'content', timefmt => 'content', + masterchan => 'content', debugchan => 'content'}) > io("$::cset/settings.xml"); writeChannels(); writeUsers(); writeRestrictions(); |
