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,16 +302,24 @@ 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}) {
|
||||||
if(++$self->message_history->{$account}->{channels}->{$channel}{enter_abuse} >= $self->{ENTER_ABUSE_MAX_LINES} - 1) {
|
my %msg = %{ @{ $self->message_history->{$account}->{channels}->{$channel}{messages} }[$length - 2] };
|
||||||
$self->message_history->{$account}->{channels}->{$channel}{enter_abuse} = $self->{ENTER_ABUSE_MAX_LINES} / 2 - 1;
|
my %last = %{ @{ $self->message_history->{$account}->{channels}->{$channel}{messages} }[$length - 1] };
|
||||||
if(++$self->message_history->{$account}->{channels}->{$channel}{enter_abuses} >= $self->{ENTER_ABUSE_MAX_OFFENSES}) {
|
|
||||||
my $offenses = $self->message_history->{$account}->{channels}->{$channel}{enter_abuses} - $self->{ENTER_ABUSE_MAX_OFFENSES} + 1;
|
if($last{timestamp} - $msg{timestamp} <= 10) {
|
||||||
my $ban_length = $offenses ** $offenses * $offenses * 30;
|
if(++$self->message_history->{$account}->{channels}->{$channel}{enter_abuse} >= $self->{ENTER_ABUSE_MAX_LINES} - 1) {
|
||||||
$self->{pbot}->chanops->ban_user_timed("*!$user\@$host", $channel, $ban_length);
|
$self->message_history->{$account}->{channels}->{$channel}{enter_abuse} = $self->{ENTER_ABUSE_MAX_LINES} / 2 - 1;
|
||||||
$ban_length = duration($ban_length);
|
if(++$self->message_history->{$account}->{channels}->{$channel}{enter_abuses} >= $self->{ENTER_ABUSE_MAX_OFFENSES}) {
|
||||||
$self->{pbot}->logger->log("$nick $channel enter abuse offense " . $self->message_history->{$account}->{channels}->{$channel}{enter_abuses} . " earned $ban_length ban\n");
|
my $offenses = $self->message_history->{$account}->{channels}->{$channel}{enter_abuses} - $self->{ENTER_ABUSE_MAX_OFFENSES} + 1;
|
||||||
$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.");
|
my $ban_length = $offenses ** $offenses * $offenses * 30;
|
||||||
|
$self->{pbot}->chanops->ban_user_timed("*!$user\@$host", $channel, $ban_length);
|
||||||
|
$ban_length = duration($ban_length);
|
||||||
|
$self->{pbot}->logger->log("$nick $channel enter abuse offense " . $self->message_history->{$account}->{channels}->{$channel}{enter_abuses} . " earned $ban_length ban\n");
|
||||||
|
$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;
|
||||||
|
@ -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