From 1155205f0ec0fc76765e4449d8423c78368dd600 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 22 Oct 2013 18:57:08 +0000 Subject: [PATCH] Bot now keeps message history for itself -- can now be grabbed for quotegrabs --- PBot/AntiFlood.pm | 5 +++-- PBot/Interpreter.pm | 6 ++++++ PBot/VERSION.pm | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/PBot/AntiFlood.pm b/PBot/AntiFlood.pm index 296f8647..5a3d9e2d 100644 --- a/PBot/AntiFlood.pm +++ b/PBot/AntiFlood.pm @@ -218,8 +218,6 @@ sub check_flood { $user = lc $user; $host = lc $host; - return if $nick eq lc $self->{pbot}->botnick; - my $account = $self->get_flood_account($nick, $user, $host); if(not defined $account) { @@ -268,6 +266,9 @@ sub check_flood { my $length = $self->add_message($account, $channel, $text, $mode); return if not defined $length; + # do not do flood processing for bot messages + return if $nick eq lc $self->{pbot}->botnick; + # do not do flood processing if channel is not in bot's channel list or bot is not set as chanop for the channel return if ($channel =~ /^#/) and (not exists $self->{pbot}->channels->channels->hash->{$channel} or $self->{pbot}->channels->channels->hash->{$channel}{chanop} == 0); diff --git a/PBot/Interpreter.pm b/PBot/Interpreter.pm index 6485f180..69a6ef7c 100644 --- a/PBot/Interpreter.pm +++ b/PBot/Interpreter.pm @@ -170,8 +170,10 @@ sub process_line { if($result =~ s/^\/say\s+//i) { $pbot->conn->privmsg($from, $result) if defined $from && $from !~ /\Q$mynick\E/i; + $pbot->antiflood->check_flood($from, $pbot->{botnick}, $pbot->{username}, 'localhost', $result, 0, 0, 0); } elsif($result =~ s/^\/me\s+//i) { $pbot->conn->me($from, $result) if defined $from && $from !~ /\Q$mynick\E/i; + $pbot->antiflood->check_flood($from, $pbot->{botnick}, $pbot->{username}, 'localhost', '/me ' . $result, 0, 0, 0); } elsif($result =~ s/^\/msg\s+([^\s]+)\s+//i) { my $to = $1; if($to =~ /,/) { @@ -182,14 +184,18 @@ sub process_line { } elsif($result =~ s/^\/me\s+//i) { $pbot->conn->me($to, $result) if $to !~ /\Q$mynick\E/i; + $pbot->antiflood->check_flood($to, $pbot->{botnick}, $pbot->{username}, 'localhost', '/me ' . $result, 0, 0, 0); } else { $result =~ s/^\/say\s+//i; $pbot->conn->privmsg($to, $result) if $to !~ /\Q$mynick\E/i; + $pbot->antiflood->check_flood($to, $pbot->{botnick}, $pbot->{username}, 'localhost', $result, 0, 0, 0); } } else { $pbot->conn->privmsg($from, $result) if defined $from && $from !~ /\Q$mynick\E/i; + $pbot->antiflood->check_flood($from, $pbot->{botnick}, $pbot->{username}, 'localhost', $result, 0, 0, 0); } } + $pbot->logger->log("---------------------------------------------\n"); # TODO: move this to FactoidModuleLauncher somehow, completely out of Interpreter! diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index 2983ce0c..399c3de1 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,8 +13,8 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 455, - BUILD_DATE => "2013-10-19", + BUILD_REVISION => 456, + BUILD_DATE => "2013-10-22", }; 1;