From 99be204a95caeff0a7b15c46fd680028c2d6722f Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 10 Dec 2017 13:18:00 -0800 Subject: [PATCH] Add per-channel ratelimit_override registry object to ... override factoid ratelimits on a per-channel basis --- PBot/Factoids.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 28eb5fbf..a8fc4173 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -830,8 +830,10 @@ sub interpreter { if (exists $self->{factoids}->hash->{$channel}->{$keyword}->{last_referenced_on}) { if (exists $self->{factoids}->hash->{$channel}->{$keyword}->{last_referenced_in}) { if ($self->{factoids}->hash->{$channel}->{$keyword}->{last_referenced_in} eq $stuff->{from}) { - if (gettimeofday - $self->{factoids}->hash->{$channel}->{$keyword}->{last_referenced_on} < $self->{factoids}->hash->{$channel}->{$keyword}->{rate_limit}) { - return "/msg $stuff->{nick} $stuff->{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, "$stuff->{nick}!$stuff->{user}\@$stuff->{host}"); + my $ratelimit = $self->{pbot}->{registry}->get_value($channel, 'ratelimit_override'); + $ratelimit = $self->{factoids}->hash->{$channel}->{$keyword}->{rate_limit} if not defined $ratelimit; + if (gettimeofday - $self->{factoids}->hash->{$channel}->{$keyword}->{last_referenced_on} < $ratelimit) { + return "/msg $stuff->{nick} $stuff->{ref_from}'$keyword' is rate-limited; try again in " . duration ($ratelimit - int(gettimeofday - $self->{factoids}->hash->{$channel}->{$keyword}->{last_referenced_on})) . "." unless $self->{pbot}->{admins}->loggedin($channel, "$stuff->{nick}!$stuff->{user}\@$stuff->{host}"); } } }