Add per-channel ratelimit_override registry object to ... override factoid ratelimits on a per-channel basis

This commit is contained in:
Pragmatic Software 2017-12-10 13:18:00 -08:00
parent e0b03ee3d4
commit 99be204a95
1 changed files with 4 additions and 2 deletions

View File

@ -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}");
}
}
}