mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 11:12:42 +01:00
Refactored AntiFlood account code -- much improved
This commit is contained in:
parent
347bb86bac
commit
ef3d9770ca
@ -75,8 +75,17 @@ sub check_flood {
|
||||
|
||||
my $account = $self->get_flood_account($nick, $user, $host);
|
||||
|
||||
if(defined $account) {
|
||||
#$self->{pbot}->logger->log("nick exists\n");
|
||||
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;
|
||||
}
|
||||
|
||||
if(not exists ${ $self->message_history }{$account}{$channel}) {
|
||||
#$self->{pbot}->logger->log("adding new channel for existing nick\n");
|
||||
@ -120,7 +129,7 @@ sub check_flood {
|
||||
} elsif($text =~ /^QUIT Ping timeout/) {
|
||||
# deal with ping timeouts agressively
|
||||
${ $self->message_history }{$account}{$channel}{join_watch}++;
|
||||
$self->{pbot}->logger->log("$nick $channel joinwatchannel adjusted: ${ $self->message_history }{$account}{$channel}{join_watchannel}\n");
|
||||
$self->{pbot}->logger->log("$nick $channel joinwatch adjusted: ${ $self->message_history }{$account}{$channel}{join_watch}\n");
|
||||
}
|
||||
}
|
||||
} elsif($mode == $self->{FLOOD_CHAT}) {
|
||||
@ -178,15 +187,6 @@ sub check_flood {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#$self->{pbot}->logger->log("brand new nick addition\n");
|
||||
# new addition
|
||||
${ $self->message_history }{$nick}{$channel}{offenses} = 0;
|
||||
${ $self->message_history }{$nick}{$channel}{join_watch} = $mode; # FLOOD_CHAT = 0, FLOOD_JOIN = 1
|
||||
${ $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 });
|
||||
}
|
||||
}
|
||||
|
||||
sub message_history {
|
||||
|
@ -13,7 +13,7 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 159,
|
||||
BUILD_REVISION => 160,
|
||||
BUILD_DATE => "2010-06-11",
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user