mirror of
https://github.com/pragma-/pbot.git
synced 2025-02-17 05:50:56 +01:00
AntiNickSpam: Increase severity for each additional unique nick per message
This commit is contained in:
parent
d64c806741
commit
6cb2d77e7b
@ -62,15 +62,18 @@ sub check_flood {
|
|||||||
|
|
||||||
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);
|
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);
|
||||||
|
|
||||||
my @words = split /\s+/, $msg;
|
|
||||||
$channel = lc $channel;
|
$channel = lc $channel;
|
||||||
|
my @words = split /\s+/, $msg;
|
||||||
my @nicks;
|
my @nicks;
|
||||||
|
my $severity = 0; # increasing severity for each additional unique nick in a single message
|
||||||
|
|
||||||
foreach my $word (@words) {
|
foreach my $word (@words) {
|
||||||
$word =~ s/[:;\+,\.!?\@\%\$]+$//g;
|
$word =~ s/[:;\+,\.!?\@\%\$]+$//g;
|
||||||
if ($self->{pbot}->{nicklist}->is_present($channel, $word) and not grep { $_ eq $word } @nicks) {
|
if ($self->{pbot}->{nicklist}->is_present($channel, $word) and not grep { $_ eq $word } @nicks) {
|
||||||
push @{$self->{nicks}->{$channel}}, [scalar gettimeofday, $word];
|
$severity++;
|
||||||
|
for (my $i = 0; $i < $severity; $i++) {
|
||||||
|
push @{$self->{nicks}->{$channel}}, [scalar gettimeofday, $word];
|
||||||
|
}
|
||||||
push @nicks, $word;
|
push @nicks, $word;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,8 +93,7 @@ sub clear_old_nicks {
|
|||||||
|
|
||||||
return if not exists $self->{nicks}->{$channel};
|
return if not exists $self->{nicks}->{$channel};
|
||||||
|
|
||||||
my $i = 50;
|
while (1) {
|
||||||
while (--$i > 0) {
|
|
||||||
if (@{$self->{nicks}->{$channel}} and $self->{nicks}->{$channel}->[0]->[0] <= $now - 15) {
|
if (@{$self->{nicks}->{$channel}} and $self->{nicks}->{$channel}->[0]->[0] <= $now - 15) {
|
||||||
shift @{$self->{nicks}->{$channel}};
|
shift @{$self->{nicks}->{$channel}};
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user