mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-22 20:09:43 +01:00
Added rate_limit to factoids
This commit is contained in:
parent
c150e2018c
commit
818e09861c
@ -94,6 +94,7 @@ sub add_factoid {
|
||||
$self->factoids->hash->{$channel}->{$trigger}->{created_on} = gettimeofday;
|
||||
$self->factoids->hash->{$channel}->{$trigger}->{ref_count} = 0;
|
||||
$self->factoids->hash->{$channel}->{$trigger}->{ref_user} = "nobody";
|
||||
$self->factoids->hash->{$channel}->{$trigger}->{rate_limit} = 15;
|
||||
|
||||
$self->save_factoids;
|
||||
}
|
||||
@ -227,10 +228,17 @@ sub interpreter {
|
||||
return $pbot->interpreter->interpret($from, $nick, $user, $host, $count, $command);
|
||||
}
|
||||
|
||||
if(exists $self->factoids->hash->{$channel}->{$keyword}->{last_referenced_on}) {
|
||||
if(gettimeofday - $self->factoids->hash->{$channel}->{$keyword}->{last_referenced_on} <= $self->factoids->hash->{$channel}->{$keyword}->{rate_limit}) {
|
||||
return "/msg $nick '$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.";
|
||||
}
|
||||
}
|
||||
|
||||
if($self->factoids->hash->{$channel}->{$keyword}->{enabled} == 0) {
|
||||
$self->{pbot}->logger->log("$keyword disabled.\n");
|
||||
return "/msg $nick $keyword is currently disabled.";
|
||||
} elsif($self->factoids->hash->{$channel}->{$keyword}->{type} eq 'module') {
|
||||
}
|
||||
elsif($self->factoids->hash->{$channel}->{$keyword}->{type} eq 'module') {
|
||||
$self->{pbot}->logger->log("Found module\n");
|
||||
|
||||
$self->factoids->hash->{$channel}->{$keyword}->{ref_count}++;
|
||||
|
@ -13,7 +13,7 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 194,
|
||||
BUILD_REVISION => 195,
|
||||
BUILD_DATE => "2010-06-21",
|
||||
};
|
||||
|
||||
|
1071
data/factoids
1071
data/factoids
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user