mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-27 06:19:25 +01:00
anti-flood: Enter abuse now requires 10 seconds or less between messages
This commit is contained in:
parent
087c819069
commit
1831d0775d
@ -302,6 +302,10 @@ sub check_flood {
|
|||||||
|
|
||||||
if($mode == $self->{FLOOD_CHAT} and $channel =~ m/^#/) {
|
if($mode == $self->{FLOOD_CHAT} and $channel =~ m/^#/) {
|
||||||
if(defined $self->{channels}->{$channel}->{last_spoken_nick} and $nick eq $self->{channels}->{$channel}->{last_spoken_nick}) {
|
if(defined $self->{channels}->{$channel}->{last_spoken_nick} and $nick eq $self->{channels}->{$channel}->{last_spoken_nick}) {
|
||||||
|
my %msg = %{ @{ $self->message_history->{$account}->{channels}->{$channel}{messages} }[$length - 2] };
|
||||||
|
my %last = %{ @{ $self->message_history->{$account}->{channels}->{$channel}{messages} }[$length - 1] };
|
||||||
|
|
||||||
|
if($last{timestamp} - $msg{timestamp} <= 10) {
|
||||||
if(++$self->message_history->{$account}->{channels}->{$channel}{enter_abuse} >= $self->{ENTER_ABUSE_MAX_LINES} - 1) {
|
if(++$self->message_history->{$account}->{channels}->{$channel}{enter_abuse} >= $self->{ENTER_ABUSE_MAX_LINES} - 1) {
|
||||||
$self->message_history->{$account}->{channels}->{$channel}{enter_abuse} = $self->{ENTER_ABUSE_MAX_LINES} / 2 - 1;
|
$self->message_history->{$account}->{channels}->{$channel}{enter_abuse} = $self->{ENTER_ABUSE_MAX_LINES} / 2 - 1;
|
||||||
if(++$self->message_history->{$account}->{channels}->{$channel}{enter_abuses} >= $self->{ENTER_ABUSE_MAX_OFFENSES}) {
|
if(++$self->message_history->{$account}->{channels}->{$channel}{enter_abuses} >= $self->{ENTER_ABUSE_MAX_OFFENSES}) {
|
||||||
@ -313,6 +317,10 @@ sub check_flood {
|
|||||||
$self->{pbot}->conn->privmsg($nick, "You have been muted due to abusing the enter key. Please do not split your sentences over multiple messages. You will be allowed to speak again in $ban_length.");
|
$self->{pbot}->conn->privmsg($nick, "You have been muted due to abusing the enter key. Please do not split your sentences over multiple messages. You will be allowed to speak again in $ban_length.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
# $self->{pbot}->logger->log("$nick $channel more than 10 seconds since last message, enter abuse counter reset\n");
|
||||||
|
$self->message_history->{$account}->{channels}->{$channel}{enter_abuse} = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$self->{channels}->{$channel}->{last_spoken_nick} = $nick;
|
$self->{channels}->{$channel}->{last_spoken_nick} = $nick;
|
||||||
$self->message_history->{$account}->{channels}->{$channel}{enter_abuse} = 0;
|
$self->message_history->{$account}->{channels}->{$channel}{enter_abuse} = 0;
|
||||||
|
@ -13,8 +13,8 @@ use warnings;
|
|||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 522,
|
BUILD_REVISION => 523,
|
||||||
BUILD_DATE => "2014-03-12",
|
BUILD_DATE => "2014-03-13",
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user