3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-29 23:39:24 +01:00

AntiFlood: disregard unreg spam floods on +z channels

This commit is contained in:
Pragmatic Software 2018-08-13 14:25:35 -07:00
parent 8e615fe6a3
commit 75f6d86a88
2 changed files with 24 additions and 7 deletions

View File

@ -292,7 +292,7 @@ sub update_join_watch {
} }
sub check_flood { sub check_flood {
my ($self, $channel, $nick, $user, $host, $text, $max_messages, $max_time, $mode) = @_; my ($self, $channel, $nick, $user, $host, $text, $max_messages, $max_time, $mode, $stuff) = @_;
$channel = lc $channel; $channel = lc $channel;
my $mask = "$nick!$user\@$host"; my $mask = "$nick!$user\@$host";
@ -346,6 +346,11 @@ sub check_flood {
return; return;
} }
# don't do flood processing for unidentified or banned users in +z channels
if (defined $stuff and $stuff->{'chan-z'} and ($stuff->{'unidentified'} or $stuff->{'banned'})) {
return;
}
my $ancestor = $self->{pbot}->{messagehistory}->{database}->get_ancestor_id($account); my $ancestor = $self->{pbot}->{messagehistory}->{database}->get_ancestor_id($account);
$self->{pbot}->{logger}->log("Processing anti-flood account $account " . ($ancestor != $account ? "[ancestor $ancestor] " : '') . "for mask $mask\n") if $self->{pbot}->{registry}->get_value('antiflood', 'debug_account'); $self->{pbot}->{logger}->log("Processing anti-flood account $account " . ($ancestor != $account ? "[ancestor $ancestor] " : '') . "for mask $mask\n") if $self->{pbot}->{registry}->get_value('antiflood', 'debug_account');

View File

@ -69,19 +69,31 @@ sub process_line {
$flood_threshold = $pbot->{registry}->get_value('antiflood', 'chat_flood_threshold') if not defined $flood_threshold; $flood_threshold = $pbot->{registry}->get_value('antiflood', 'chat_flood_threshold') if not defined $flood_threshold;
$flood_time_threshold = $pbot->{registry}->get_value('antiflood', 'chat_flood_time_threshold') if not defined $flood_time_threshold; $flood_time_threshold = $pbot->{registry}->get_value('antiflood', 'chat_flood_time_threshold') if not defined $flood_time_threshold;
$pbot->{antiflood}->check_flood($from, $nick, $user, $host, $text,
$flood_threshold, $flood_time_threshold,
$pbot->{messagehistory}->{MSG_CHAT}) if defined $from;
if (defined $from and $from =~ m/^#/) { if (defined $from and $from =~ m/^#/) {
my $chanmodes = $self->{pbot}->{channels}->get_meta($from, 'MODE'); my $chanmodes = $self->{pbot}->{channels}->get_meta($from, 'MODE');
if (defined $chanmodes and $chanmodes =~ m/z/) { if (defined $chanmodes and $chanmodes =~ m/z/) {
$stuff->{'chan-z'} = 1;
if (exists $self->{pbot}->{bantracker}->{banlist}->{$from}->{'+q'}->{'$~a'}) {
my $nickserv = $self->{pbot}->{messagehistory}->{database}->get_current_nickserv_account($message_account);
if (not defined $nickserv or not length $nickserv) {
$stuff->{unidentified} = 1;
}
}
if ($self->{pbot}->{bantracker}->is_banned($nick, $user, $host, $from)) { if ($self->{pbot}->{bantracker}->is_banned($nick, $user, $host, $from)) {
$stuff->{banned} = 1;
}
}
}
$pbot->{antiflood}->check_flood($from, $nick, $user, $host, $text,
$flood_threshold, $flood_time_threshold,
$pbot->{messagehistory}->{MSG_CHAT}, $stuff) if defined $from;
if ($stuff->{banned}) {
$self->{pbot}->{logger}->log("Disregarding banned user message (channel $from is +z).\n"); $self->{pbot}->{logger}->log("Disregarding banned user message (channel $from is +z).\n");
return 1; return 1;
} }
}
}
my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick'); my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick');