mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 11:12:42 +01:00
Ping timeout QUITs now properly added to each channel's message history
This commit is contained in:
parent
f14924a619
commit
811e2e71d2
@ -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] };
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user