From 999d8ae4a8e4dad7da1211ecf852c3ce81c9184c Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 27 Jun 2010 05:36:58 +0000 Subject: [PATCH] Added Time::Duration to anti-flood join history --- PBot/AntiFlood.pm | 5 +++-- PBot/VERSION.pm | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/PBot/AntiFlood.pm b/PBot/AntiFlood.pm index bb1bd8b1..699cb673 100644 --- a/PBot/AntiFlood.pm +++ b/PBot/AntiFlood.pm @@ -16,6 +16,7 @@ use vars qw($VERSION); $VERSION = $PBot::PBot::VERSION; use Time::HiRes qw(gettimeofday); +use Time::Duration; use Carp (); sub new { @@ -191,7 +192,7 @@ sub check_flood { my $i = $length - 1; $self->{pbot}->logger->log("Checking flood history, i = $i\n"); for(; $i >= 0; $i--) { - $self->{pbot}->logger->log($i . " " . $self->message_history->{$account}{$channel}{messages}->[$i]{mode} ." " . $self->message_history->{$account}{$channel}{messages}->[$i]{msg} . " " . $self->message_history->{$account}{$channel}{messages}->[$i]{timestamp} . "\n"); + $self->{pbot}->logger->log($i . " " . $self->message_history->{$account}{$channel}{messages}->[$i]{mode} ." " . $self->message_history->{$account}{$channel}{messages}->[$i]{msg} . " " . $self->message_history->{$account}{$channel}{messages}->[$i]{timestamp} . " [" . ago_exact(time - $self->message_history->{$account}{$channel}{messages}->[$i]{timestamp}) . "]\n"); next if $self->message_history->{$account}{$channel}{messages}->[$i]{mode} != $self->{FLOOD_JOIN}; last if ++$count >= 4; } @@ -201,7 +202,7 @@ sub check_flood { my %last = %{ @{ ${ $self->message_history }{$account}{$channel}{messages} }[$length - 1] }; - $self->{pbot}->logger->log("Comparing " . int($last{timestamp}) . " against " . int($msg{timestamp}) . ": " . (int($last{timestamp} - $msg{timestamp})) . " seconds\n") if $mode == $self->{FLOOD_JOIN}; + $self->{pbot}->logger->log("Comparing " . int($last{timestamp}) . " against " . int($msg{timestamp}) . ": " . (int($last{timestamp} - $msg{timestamp})) . " seconds [" . ago_exact($last{timestamp} - $msg{timestamp}) . "]\n") if $mode == $self->{FLOOD_JOIN}; if($last{timestamp} - $msg{timestamp} <= $max_time && not $self->{pbot}->admins->loggedin($channel, "$nick!$user\@$host")) { if($mode == $self->{FLOOD_JOIN}) { diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index 9582d4ee..1c20bb3a 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,7 +13,7 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 206, + BUILD_REVISION => 207, BUILD_DATE => "2010-06-26", };