3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-03 01:48:38 +02:00

Interpreter: tell <nick> about <command> now case-insensitive

AntiFlood: Correct use of ignore list
IgnoreList: Ignoring user without args now permanent instead of 5 mins
            Save time when ignore expires instead of seconds remaining
            Improve output of `ignore list` command for readability
This commit is contained in:
Pragmatic Software 2012-09-06 10:09:44 +00:00
parent a0bcdfef2f
commit 2b5ff48a4c
5 changed files with 23 additions and 18 deletions

View File

@ -347,7 +347,7 @@ sub check_flood {
$self->{pbot}->conn->privmsg($nick, "You have been muted due to flooding. Please use a web paste service such as http://codepad.org for lengthy pastes. You will be allowed to speak again in $length.");
}
else { # private message flood
return if exists $self->{pbot}->ignorelist->{ignore_list}->{"$nick!$user\@$host"}->{channels}->{$channel};
return if exists ${ $self->{pbot}->ignorelist->{ignore_list} }{"$nick!$user\@$host"}{$channel};
$self->{pbot}->logger->log("$nick msg flood offense " . $self->message_history->{$account}->{channels}->{$channel}{offenses} . " earned $length second ignore\n");
@ -381,7 +381,6 @@ sub prune_message_history {
$self->{pbot}->logger->log("Checking [$mask][$channel]\n");
my $length = $#{ $self->{message_history}->{$mask}->{channels}->{$channel}{messages} } + 1;
$self->{pbot}->logger->log("length: $length\n");
next unless $length > 0;
my %last = %{ @{ $self->{message_history}->{$mask}->{channels}->{$channel}{messages} }[$length - 1] };
@ -450,7 +449,12 @@ sub unbanme {
}
}
}
my $account = $self->get_flood_account($nick, $user, $host);
if(defined $account and $self->message_history->{$account}->{channels}->{$channel}{offenses} > 2) {
return "/msg $nick You may only use unbanme for the first two offenses. You will be automatically unbanned in a few hours, and your offense counter will decrement once every 24 hours.";
}
$self->{pbot}->chanops->unban_user($mask, $channel);
delete $self->{pbot}->chanops->{unban_timeout}->hash->{$mask};
$self->{pbot}->chanops->{unban_timeout}->save_hash();

View File

@ -98,11 +98,7 @@ sub load_ignores {
Carp::croak "Duplicate ignore [$hostmask][$channel] found in $filename around line $i\n";
}
if($length == -1) {
${ $self->{ignore_list} }{$hostmask}{$channel} = $length;
} else {
${ $self->{ignore_list} }{$hostmask}{$channel} = gettimeofday + $length;
}
${ $self->{ignore_list} }{$hostmask}{$channel} = $length;
}
$self->{pbot}->logger->log(" $i entries in ignorelist\n");
@ -125,7 +121,6 @@ sub save_ignores {
foreach my $ignored (keys %{ $self->{ignore_list} }) {
foreach my $ignored_channel (keys %{ ${ $self->{ignore_list} }{$ignored} }) {
my $length = $self->{ignore_list}->{$ignored}{$ignored_channel};
$length = int($length - gettimeofday) unless $length == -1;
print FILE "$ignored $ignored_channel $length\n";
}
}
@ -174,7 +169,13 @@ sub check_ignore {
foreach my $ignored (keys %{ $self->{ignore_list} }) {
foreach my $ignored_channel (keys %{ ${ $self->{ignore_list} }{$ignored} }) {
#$self->{pbot}->logger->log("check_ignore: comparing '$hostmask' against '$ignored' for channel '$channel'\n");
if(($channel =~ /\Q$ignored_channel\E/i) && ($hostmask =~ /\Q$ignored\E/i)) {
my $ignored_channel_escaped = quotemeta $ignored_channel;
my $ignored_escaped = quotemeta $ignored;
$ignored_channel_escaped =~ s/\\(\.|\*)/$1/g;
$ignored_escaped =~ s/\\(\.|\*)/$1/g;
if(($channel =~ /$ignored_channel_escaped/i) && ($hostmask =~ /$ignored_escaped/i)) {
$self->{pbot}->logger->log("$nick!$user\@$host message ignored in channel $channel (matches [$ignored] host and [$ignored_channel] channel)\n");
return 1;
}

View File

@ -58,8 +58,8 @@ sub ignore_user {
foreach my $ignored (keys %{ $self->{pbot}->ignorelist->{ignore_list} }) {
foreach my $channel (keys %{ ${ $self->{pbot}->ignorelist->{ignore_list} }{$ignored} }) {
$text .= $sep . "[$ignored][$channel]" . int(gettimeofday - ${ $self->{pbot}->ignorelist->{ignore_list} }{$ignored}{$channel});
$sep = "; ";
$text .= $sep . "[$ignored]->[$channel]->[" . (${ $self->{pbot}->ignorelist->{ignore_list} }{$ignored}{$channel} == -1 ? -1 : int(gettimeofday - ${ $self->{pbot}->ignorelist->{ignore_list} }{$ignored}{$channel})) . "]";
$sep = ";\n";
}
}
return "/msg $nick $text";
@ -70,7 +70,7 @@ sub ignore_user {
}
if(not defined $length) {
$length = 300; # 5 minutes
$length = -1; # permanently
}
$self->{pbot}->logger->log("$nick added [$target][$channel] to ignore list for $length seconds\n");

View File

@ -216,11 +216,11 @@ sub interpret {
if($command =~ /^tell\s+(.{1,20})\s+about\s+(.*?)\s+(.*)$/i)
{
($keyword, $arguments, $tonick) = ($2, $3, $1);
} elsif($command =~ /^tell\s+(.{1,20})\s+about\s+(.*)$/) {
} elsif($command =~ /^tell\s+(.{1,20})\s+about\s+(.*)$/i) {
($keyword, $tonick) = ($2, $1);
} elsif($command =~ /^([^ ]+)\s+is\s+also\s+(.*)$/) {
} elsif($command =~ /^([^ ]+)\s+is\s+also\s+(.*)$/i) {
($keyword, $arguments) = ("change", "$1 s|\$| - $2|");
} elsif($command =~ /^([^ ]+)\s+is\s+(.*)$/) {
} elsif($command =~ /^([^ ]+)\s+is\s+(.*)$/i) {
my ($k, $a) = ($1, $2);
$self->{pbot}->logger->log("calling find_factoid in Interpreter.pm, interpret() for factadd\n");

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 382,
BUILD_DATE => "2012-09-03",
BUILD_REVISION => 383,
BUILD_DATE => "2012-09-06",
};
1;