mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 19:22:40 +01:00
Correct bug from refactoring AntiFlood.pm previously; no longer crashes on pruning message history
This commit is contained in:
parent
f9ab0c7e77
commit
38e7de9f41
@ -87,24 +87,16 @@ sub add_message {
|
||||
# PART or QUIT
|
||||
# check QUIT message for netsplits, and decrement joinwatch if found
|
||||
if($text =~ /^QUIT .*\.net .*\.split/) {
|
||||
foreach my $ch (keys %{ $self->message_history->{$account} }) {
|
||||
next if $ch eq 'hostmask'; # TODO: move channels into {channel} subkey
|
||||
next if $ch !~ /^#/;
|
||||
${ $self->message_history }{$account}{$ch}{join_watch}--;
|
||||
${ $self->message_history }{$account}{$ch}{join_watch} = 0 if ${ $self->message_history }{$account}{$ch}{join_watch} < 0;
|
||||
$self->{pbot}->logger->log("$account $ch joinwatch adjusted: ${ $self->message_history }{$account}{$ch}{join_watch}\n");
|
||||
}
|
||||
${ $self->message_history }{$account}{$channel}{join_watch}--;
|
||||
${ $self->message_history }{$account}{$channel}{join_watch} = 0 if ${ $self->message_history }{$account}{$channel}{join_watch} < 0;
|
||||
$self->{pbot}->logger->log("$account $channel joinwatch adjusted: ${ $self->message_history }{$account}{$channel}{join_watch}\n");
|
||||
$self->message_history->{$account}{$channel}{messages}->[$length - 1]{mode} = $self->{FLOOD_IGNORE};
|
||||
}
|
||||
# check QUIT message for Ping timeout
|
||||
elsif($text =~ /^QUIT Ping timeout/) {
|
||||
# deal with ping timeouts agressively
|
||||
foreach my $ch (keys %{ $self->message_history->{$account} }) {
|
||||
next if $ch eq 'hostmask'; # TODO: move channels into {channel} subkey
|
||||
next if $ch !~ /^#/;
|
||||
${ $self->message_history }{$account}{$ch}{join_watch}++;
|
||||
$self->{pbot}->logger->log("$account $ch joinwatch adjusted: ${ $self->message_history }{$account}{$ch}{join_watch}\n");
|
||||
}
|
||||
${ $self->message_history }{$account}{$channel}{join_watch}++;
|
||||
$self->{pbot}->logger->log("$account $channel joinwatch adjusted: ${ $self->message_history }{$account}{$channel}{join_watch}\n");
|
||||
} else {
|
||||
# some other type of QUIT or PART
|
||||
$self->message_history->{$account}{$channel}{messages}->[$length - 1]{mode} = $self->{FLOOD_IGNORE};
|
||||
@ -147,13 +139,6 @@ sub check_flood {
|
||||
$account = $nick;
|
||||
}
|
||||
|
||||
if(not exists ${ $self->message_history }{$account}{$channel}) {
|
||||
#$self->{pbot}->logger->log("adding new channel for existing nick\n");
|
||||
${ $self->message_history }{$account}{$channel}{offenses} = 0;
|
||||
${ $self->message_history }{$account}{$channel}{join_watch} = 0;
|
||||
${ $self->message_history }{$account}{$channel}{messages} = [];
|
||||
}
|
||||
|
||||
# handle QUIT events
|
||||
# (these events come from $channel nick!user@host, not a specific channel or nick,
|
||||
# so they need to be dispatched to all channels the bot exists on)
|
||||
@ -177,6 +162,13 @@ sub check_flood {
|
||||
return;
|
||||
}
|
||||
|
||||
if(not exists ${ $self->message_history }{$account}{$channel}) {
|
||||
#$self->{pbot}->logger->log("adding new channel for existing nick\n");
|
||||
${ $self->message_history }{$account}{$channel}{offenses} = 0;
|
||||
${ $self->message_history }{$account}{$channel}{join_watch} = 0;
|
||||
${ $self->message_history }{$account}{$channel}{messages} = [];
|
||||
}
|
||||
|
||||
my $length = $self->add_message($account, $channel, $text, $mode);
|
||||
return if not defined $length;
|
||||
|
||||
@ -204,7 +196,6 @@ sub check_flood {
|
||||
last if ++$count >= 4;
|
||||
}
|
||||
$i = 0 if $i < 0;
|
||||
print "using $i\n";
|
||||
%msg = %{ @{ ${ $self->message_history }{$account}{$channel}{messages} }[$i] };
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 188,
|
||||
BUILD_REVISION => 189,
|
||||
BUILD_DATE => "2010-06-21",
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user