3
0
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:
Pragmatic Software 2014-03-13 12:00:28 +00:00
parent 087c819069
commit 1831d0775d
2 changed files with 19 additions and 11 deletions

View File

@ -302,16 +302,24 @@ sub check_flood {
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(++$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;
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;
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.");
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) {
$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}) {
my $offenses = $self->message_history->{$account}->{channels}->{$channel}{enter_abuses} - $self->{ENTER_ABUSE_MAX_OFFENSES} + 1;
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 {
$self->{channels}->{$channel}->{last_spoken_nick} = $nick;

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 522,
BUILD_DATE => "2014-03-12",
BUILD_REVISION => 523,
BUILD_DATE => "2014-03-13",
};
1;