From 381b4bee4bf33d94b45840f887125f7358b42843 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 4 Aug 2017 21:05:31 -0700 Subject: [PATCH] Use Time::Duration for rate_limit message --- PBot/Factoids.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 9fac7fa2..8bfe9bc9 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -17,6 +17,7 @@ no if $] >= 5.018, warnings => "experimental::smartmatch"; use HTML::Entities; use Time::HiRes qw(gettimeofday); +use Time::Duration qw(duration); use Carp (); use POSIX qw(strftime); use Text::ParseWords; @@ -589,7 +590,7 @@ sub interpreter { if(exists $self->{factoids}->hash->{$channel}->{$keyword}->{last_referenced_in}) { if($self->{factoids}->hash->{$channel}->{$keyword}->{last_referenced_in} eq $from) { if(gettimeofday - $self->{factoids}->hash->{$channel}->{$keyword}->{last_referenced_on} < $self->{factoids}->hash->{$channel}->{$keyword}->{rate_limit}) { - return "/msg $nick $ref_from'$keyword' is rate-limited; try again in " . ($self->{factoids}->hash->{$channel}->{$keyword}->{rate_limit} - int(gettimeofday - $self->{factoids}->hash->{$channel}->{$keyword}->{last_referenced_on})) . " seconds." unless $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host"); + return "/msg $nick $ref_from'$keyword' is rate-limited; try again in " . duration ($self->{factoids}->hash->{$channel}->{$keyword}->{rate_limit} - int(gettimeofday - $self->{factoids}->hash->{$channel}->{$keyword}->{last_referenced_on})) . "." unless $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host"); } } }