3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 19:22:40 +01:00

factoids: levenshtein search working again; rate-limit working again

This commit is contained in:
Pragmatic Software 2011-01-30 06:29:05 +00:00
parent e4019895d3
commit 845dff008e
2 changed files with 14 additions and 7 deletions

View File

@ -203,11 +203,18 @@ sub interpreter {
return undef if not length $keyword;
$from = lc $from;
$ref_from = "" if not defined $ref_from;
# search for factoid against global channel and current channel (from)
# search for factoid against global channel and current channel (from unless ref_from is defined)
my $original_keyword = $keyword;
($channel, $keyword) = $self->find_factoid($from, $keyword, $arguments);
($channel, $keyword) = $self->find_factoid($ref_from ? $ref_from : $from, $keyword, $arguments);
if(not defined $ref_from) {
$ref_from = "";
} else {
$ref_from = "[$ref_from] ";
}
$arguments = "" if not defined $arguments;
# if no match found, attempt to call factoid from another channel if it exists there
if(not defined $keyword) {
@ -238,12 +245,12 @@ sub interpreter {
elsif($found == 1) {
$pbot->logger->log("Found '$original_keyword' as '$fwd_trig' in [$fwd_chan]\n");
return $ref_from . $pbot->factoids->interpreter($fwd_chan, $nick, $user, $host, $count, $fwd_trig, $arguments, undef, "[$fwd_chan] ");
return $ref_from . $pbot->factoids->interpreter($from, $nick, $user, $host, $count, $fwd_trig, $arguments, undef, $fwd_chan);
}
# otherwise keyword hasn't been found, display similiar matches for all channels
else {
# if a non-nick argument was supplied, e.g., a sentence using the bot's nick, don't say anything
return "" if $arguments !~ /^[^.+-, ]{1,20}$/;
return "" if length $arguments and $arguments !~ /^[^.+-, ]{1,20}$/;
# find matches from all channels
my $matches = $self->factoids->levenshtein_matches('.*', lc $original_keyword);

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 285,
BUILD_REVISION => 286,
BUILD_DATE => "2011-01-29",
};