From 0293b9d684ce2f89a1850b7a0d4819bdd1c947ef Mon Sep 17 00:00:00 2001 From: William Heimbigner Date: Sun, 25 Nov 2007 21:33:40 +0000 Subject: better logging, better flood detection, command ignoring --- modules/classes.pl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'modules/classes.pl') diff --git a/modules/classes.pl b/modules/classes.pl index 36a8031..775eae6 100644 --- a/modules/classes.pl +++ b/modules/classes.pl @@ -17,6 +17,7 @@ sub new "floodqueue" => \&floodqueue, "nickspam" => \&nickspam, "splitflood" => \&splitflood, + "advsplitflood" => \&advsplitflood, "re" => \&re, "nick" => \&nick, "ident" => \&ident, @@ -151,6 +152,37 @@ sub splitflood { return 0; } +sub advsplitflood { + my ($chk, $id, $event, $chan) = @_; + my $text; + my @cut = split(/:/, $chk->{content}); + $cf{$id}{timeout}=int($cut[1]); + if ($event->{type} =~ /^(public|notice|part|caction)$/) { + $text=$event->{args}->[0]; + } + return unless defined($text); + $text=~s/^\d+(.*)\d+$/$1/; + return unless length($text) >= 10; + if (defined($bs{$id}{$text}) && (time <= $bs{$id}{$text} + 600)) { + return 1; + } + push( @{$cf{$id}{$chan}{$text}}, time ); + while ( time >= $cf{$id}{$chan}{$text}[0] + $cf{$id}{'timeout'} ) { + last if ( $#{$cf{$id}{$chan}{$text}} == 0 ); + shift ( @{$cf{$id}{$chan}{$text}} ); + } + $cfc = $cfc + 1; + if ( $cfc >= 100 ) { + $cfc = 0; + process_cf(); + } + if ( $#{@{$cf{$id}{$chan}{$text}}}+1 == int($cut[0]) ) { + $bs{$id}{$text} = time; + return 1; + } + return 0; +} + sub re { my ($chk, $id, $event, $chan) = @_; my $match = $event->{args}->[0]; -- cgit v1.2.3