diff --git a/PBot/AntiFlood.pm b/PBot/AntiFlood.pm index f9e1ca4a..06bc6e31 100644 --- a/PBot/AntiFlood.pm +++ b/PBot/AntiFlood.pm @@ -78,11 +78,7 @@ sub check_flood { if(not defined $account) { # new addition #$self->{pbot}->logger->log("brand new nick addition\n"); - ${ $self->message_history }{$nick}{$channel}{offenses} = 0; - ${ $self->message_history }{$nick}{$channel}{join_watch} = 0; - ${ $self->message_history }{$nick}{$channel}{messages} = []; ${ $self->message_history }{$nick}{hostmask} = "$nick!$user\@$host"; - push(@{ ${ $self->message_history }{$nick}{$channel}{messages} }, { timestamp => $now, msg => $text, mode => $mode }); $account = $nick; } @@ -95,16 +91,10 @@ sub check_flood { } #$self->{pbot}->logger->log("appending new message\n"); - push(@{ ${ $self->message_history }{$account}{$channel}{messages} }, { timestamp => $now, msg => $text, mode => $mode }); my $length = $#{ ${ $self->message_history }{$account}{$channel}{messages} } + 1; - if($max_messages > $self->{pbot}->{MAX_NICK_MESSAGES}) { - $self->{pbot}->logger->log("Warning: max_messages greater than MAX_NICK_MESSAGES; truncating.\n"); - $max_messages = $self->{pbot}->{MAX_NICK_MESSAGES}; - } - if($length >= $self->{pbot}->{MAX_NICK_MESSAGES}) { my %msg = %{ shift(@{ ${ $self->message_history }{$account}{$channel}{messages} }) }; #$self->{pbot}->logger->log("shifting message off top: $msg{msg}, $msg{timestamp}\n"); @@ -127,8 +117,8 @@ sub check_flood { ${ $self->message_history }{$account}{$chan}{offenses} = 0; ${ $self->message_history }{$account}{$chan}{join_watch} = 0; ${ $self->message_history }{$account}{$chan}{messages} = []; - push(@{ ${ $self->message_history }{$account}{$chan}{messages} }, { timestamp => $now, msg => $text, mode => $mode }); } + push(@{ ${ $self->message_history }{$account}{$chan}{messages} }, { timestamp => $now, msg => $text, mode => $mode }) unless $chan eq $channel; } # check QUIT message for netsplits, and decrement joinwatch if found @@ -157,6 +147,11 @@ sub check_flood { ${ $self->message_history }{$account}{$channel}{join_watch} = 0; } + if($max_messages > $self->{pbot}->{MAX_NICK_MESSAGES}) { + $self->{pbot}->logger->log("Warning: max_messages greater than MAX_NICK_MESSAGES; truncating.\n"); + $max_messages = $self->{pbot}->{MAX_NICK_MESSAGES}; + } + if($max_messages > 0 and $length >= $max_messages) { $self->{pbot}->logger->log("More than $max_messages messages, comparing time differences ($max_time)\n") if $mode == $self->{FLOOD_JOIN}; my %msg = %{ @{ ${ $self->message_history }{$account}{$channel}{messages} }[$length - $max_messages] }; diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index cc0af7cb..4d14398d 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,8 +13,8 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 163, - BUILD_DATE => "2010-06-11", + BUILD_REVISION => 164, + BUILD_DATE => "2010-06-12", }; 1;