mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-23 10:34:52 +01: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:
parent
a0bcdfef2f
commit
2b5ff48a4c
@ -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.");
|
$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
|
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");
|
$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");
|
$self->{pbot}->logger->log("Checking [$mask][$channel]\n");
|
||||||
my $length = $#{ $self->{message_history}->{$mask}->{channels}->{$channel}{messages} } + 1;
|
my $length = $#{ $self->{message_history}->{$mask}->{channels}->{$channel}{messages} } + 1;
|
||||||
$self->{pbot}->logger->log("length: $length\n");
|
|
||||||
next unless $length > 0;
|
next unless $length > 0;
|
||||||
my %last = %{ @{ $self->{message_history}->{$mask}->{channels}->{$channel}{messages} }[$length - 1] };
|
my %last = %{ @{ $self->{message_history}->{$mask}->{channels}->{$channel}{messages} }[$length - 1] };
|
||||||
|
|
||||||
@ -451,6 +450,11 @@ 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);
|
$self->{pbot}->chanops->unban_user($mask, $channel);
|
||||||
delete $self->{pbot}->chanops->{unban_timeout}->hash->{$mask};
|
delete $self->{pbot}->chanops->{unban_timeout}->hash->{$mask};
|
||||||
$self->{pbot}->chanops->{unban_timeout}->save_hash();
|
$self->{pbot}->chanops->{unban_timeout}->save_hash();
|
||||||
|
@ -98,11 +98,7 @@ sub load_ignores {
|
|||||||
Carp::croak "Duplicate ignore [$hostmask][$channel] found in $filename around line $i\n";
|
Carp::croak "Duplicate ignore [$hostmask][$channel] found in $filename around line $i\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($length == -1) {
|
|
||||||
${ $self->{ignore_list} }{$hostmask}{$channel} = $length;
|
${ $self->{ignore_list} }{$hostmask}{$channel} = $length;
|
||||||
} else {
|
|
||||||
${ $self->{ignore_list} }{$hostmask}{$channel} = gettimeofday + $length;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{pbot}->logger->log(" $i entries in ignorelist\n");
|
$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 (keys %{ $self->{ignore_list} }) {
|
||||||
foreach my $ignored_channel (keys %{ ${ $self->{ignore_list} }{$ignored} }) {
|
foreach my $ignored_channel (keys %{ ${ $self->{ignore_list} }{$ignored} }) {
|
||||||
my $length = $self->{ignore_list}->{$ignored}{$ignored_channel};
|
my $length = $self->{ignore_list}->{$ignored}{$ignored_channel};
|
||||||
$length = int($length - gettimeofday) unless $length == -1;
|
|
||||||
print FILE "$ignored $ignored_channel $length\n";
|
print FILE "$ignored $ignored_channel $length\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,7 +169,13 @@ sub check_ignore {
|
|||||||
foreach my $ignored (keys %{ $self->{ignore_list} }) {
|
foreach my $ignored (keys %{ $self->{ignore_list} }) {
|
||||||
foreach my $ignored_channel (keys %{ ${ $self->{ignore_list} }{$ignored} }) {
|
foreach my $ignored_channel (keys %{ ${ $self->{ignore_list} }{$ignored} }) {
|
||||||
#$self->{pbot}->logger->log("check_ignore: comparing '$hostmask' against '$ignored' for channel '$channel'\n");
|
#$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");
|
$self->{pbot}->logger->log("$nick!$user\@$host message ignored in channel $channel (matches [$ignored] host and [$ignored_channel] channel)\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,8 @@ sub ignore_user {
|
|||||||
|
|
||||||
foreach my $ignored (keys %{ $self->{pbot}->ignorelist->{ignore_list} }) {
|
foreach my $ignored (keys %{ $self->{pbot}->ignorelist->{ignore_list} }) {
|
||||||
foreach my $channel (keys %{ ${ $self->{pbot}->ignorelist->{ignore_list} }{$ignored} }) {
|
foreach my $channel (keys %{ ${ $self->{pbot}->ignorelist->{ignore_list} }{$ignored} }) {
|
||||||
$text .= $sep . "[$ignored][$channel]" . int(gettimeofday - ${ $self->{pbot}->ignorelist->{ignore_list} }{$ignored}{$channel});
|
$text .= $sep . "[$ignored]->[$channel]->[" . (${ $self->{pbot}->ignorelist->{ignore_list} }{$ignored}{$channel} == -1 ? -1 : int(gettimeofday - ${ $self->{pbot}->ignorelist->{ignore_list} }{$ignored}{$channel})) . "]";
|
||||||
$sep = "; ";
|
$sep = ";\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "/msg $nick $text";
|
return "/msg $nick $text";
|
||||||
@ -70,7 +70,7 @@ sub ignore_user {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(not defined $length) {
|
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");
|
$self->{pbot}->logger->log("$nick added [$target][$channel] to ignore list for $length seconds\n");
|
||||||
|
@ -216,11 +216,11 @@ sub interpret {
|
|||||||
if($command =~ /^tell\s+(.{1,20})\s+about\s+(.*?)\s+(.*)$/i)
|
if($command =~ /^tell\s+(.{1,20})\s+about\s+(.*?)\s+(.*)$/i)
|
||||||
{
|
{
|
||||||
($keyword, $arguments, $tonick) = ($2, $3, $1);
|
($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);
|
($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|");
|
($keyword, $arguments) = ("change", "$1 s|\$| - $2|");
|
||||||
} elsif($command =~ /^([^ ]+)\s+is\s+(.*)$/) {
|
} elsif($command =~ /^([^ ]+)\s+is\s+(.*)$/i) {
|
||||||
my ($k, $a) = ($1, $2);
|
my ($k, $a) = ($1, $2);
|
||||||
|
|
||||||
$self->{pbot}->logger->log("calling find_factoid in Interpreter.pm, interpret() for factadd\n");
|
$self->{pbot}->logger->log("calling find_factoid in Interpreter.pm, interpret() for factadd\n");
|
||||||
|
@ -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 => 382,
|
BUILD_REVISION => 383,
|
||||||
BUILD_DATE => "2012-09-03",
|
BUILD_DATE => "2012-09-06",
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user