From 6cf8963cfc8dc562f7ec8f3c5d538f05a0e7a0be Mon Sep 17 00:00:00 2001 From: William Heimbigner Date: Thu, 16 Aug 2012 06:58:14 +0000 Subject: Disabled message-sending-throttling Added a command to view uptime/cpu/ram usage statistics The hilight/dehilight commands can accept a comma-separated list of nicks The exempt command is now deprecated A restriction-system has been added to replace the old exemption system, and also includes additional restrictions that can be added, such as "don't let this account use !ops" Added a plugin command, so other bots can have ASM generate alerts Updated users and flags Updated channel hilights Replaced code that shows up in several places to split a long privmsg into two parts with a utility function Added a detection class for fuzzy-matching against a nick blacklist Fixed some major memory leaks, the bot stays stable around 30MB rather than shooting up to 65MB after a couple of days The bot now uses nickserv REGAIN instead of ghost/release/nick Added channel modes, ban lists, and quiet lists to state tracking Ignore chanserv in netsplit detections Track time/setter when a topic is changed in a channel Monitor if a channel is set +r and is still +r 45 minutes later, if so generate an alert Print status and how long it took to sync once the bot has started and synced, and warn about failed syncings. --- modules/classes.pl | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'modules/classes.pl') diff --git a/modules/classes.pl b/modules/classes.pl index fc80da1..c8dcc54 100644 --- a/modules/classes.pl +++ b/modules/classes.pl @@ -25,7 +25,8 @@ sub new "gecos" => \&gecos, "nuhg" => \&nuhg, "levenflood" => \&levenflood, - "proxy" => \&proxy + "proxy" => \&proxy, + "nickbl" => \&nickbl }; $self->{ftbl} = $tbl; bless($self); @@ -84,6 +85,21 @@ sub levenflood return $ret; } +sub nickbl +{ + my ($chk, $id, $event, $chan) = @_; + my $nick = $event->{nick}; + $nick = $event->{args}->[0] if ($event->{type} eq 'nick'); + my ($fuzzy, $match) = split(/:/, $chk->{content}); + my @nicks = split(/,/, $match); + foreach my $item (@nicks) { + if (distance(lc $nick, lc $item) <= $fuzzy) { + return 1; + } + } + return 0; +} + sub dnsbl { my ($chk, $id, $event, $chan, $rev) = @_; @@ -147,8 +163,13 @@ sub process_cf foreach my $host ( keys %{$cf{$nid}{$xchan}} ) { next unless defined $cf{$nid}{$xchan}{$host}[0]; while ( time >= $cf{$nid}{$xchan}{$host}[0] + $cf{$nid}{'timeout'} ) { - last if ( $#{ $cf{$nid}{$xchan}{$host} } == 0 ); shift ( @{$cf{$nid}{$xchan}{$host}} ); + if ( (scalar @{$cf{$nid}{$xchan}{$host}}) == 0 ) { + delete $cf{$nid}{$xchan}{$host}; + last; + } +# last if ( $#{ $cf{$nid}{$xchan}{$host} } == 0 ); +# shift ( @{$cf{$nid}{$xchan}{$host}} ); } } } @@ -305,12 +326,34 @@ sub flood_process for my $host ( keys %{$sf{$id}{$chan}} ) { next unless defined $sf{$id}{$chan}{$host}[0]; while ( time >= $sf{$id}{$chan}{$host}[0] + $sf{$id}{'timeout'} ) { - last if ( $#{ $sf{$id}{$chan}{$host} } == 0 ); shift ( @{$sf{$id}{$chan}{$host}} ); + if ( (scalar @{$sf{$id}{$chan}{$host}}) == 0 ) { + delete $sf{$id}{$chan}{$host}; + last; + } +# last if ( $#{ $sf{$id}{$chan}{$host} } == 0 ); +# shift ( @{$sf{$id}{$chan}{$host}} ); } } } } } +sub dump +{ + #%sf, %ls, %cf, %bs + open(FH, ">", "sf.txt"); + print FH Dumper(\%sf); + close(FH); + open(FH, ">", "ls.txt"); + print FH Dumper(\%ls); + close(FH); + open(FH, ">", "cf.txt"); + print FH Dumper(\%cf); + close(FH); + open(FH, ">", "bs.txt"); + print FH Dumper(\%bs); + close(FH); +} + 1; -- cgit v1.2.3