From 39a38b58f81826c62e2098d07f5d4a1712bab357 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 4 Nov 2012 20:42:38 +0000 Subject: [PATCH] Triggering non-existent factoids now attempts to factfind (for keywords and text) before trying a levenshtein closest match (of keywords) --- PBot/FactoidCommands.pm | 6 +++--- PBot/Factoids.pm | 11 +++++++++-- PBot/VERSION.pm | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/PBot/FactoidCommands.pm b/PBot/FactoidCommands.pm index 0c934911..cfa5d710 100644 --- a/PBot/FactoidCommands.pm +++ b/PBot/FactoidCommands.pm @@ -652,14 +652,14 @@ sub factfind { if($arguments ne "") { if(not defined $argtype) { - $argtype = "with text matching '$arguments'"; + $argtype = "with text containing '$arguments'"; } else { - $argtype .= " and with text matching '$arguments'"; + $argtype .= " and with text containing '$arguments'"; } } if(not defined $argtype) { - return "/msg $nick Usage: !find [-channel] [-owner nick] [-by nick] [text]"; + return "/msg $nick Usage: factfind [-channel] [-owner nick] [-by nick] [text]"; } my ($text, $last_trigger, $last_chan, $i); diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 21027b5a..ead651e6 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -266,8 +266,15 @@ sub interpreter { # if a non-nick argument was supplied, e.g., a sentence using the bot's nick, don't say anything return "" if length $arguments and $arguments !~ /^[^.+-, ]{1,20}$/; - # find matches from all channels - my $matches = $self->factoids->levenshtein_matches('.*', lc $original_keyword); + my $matches = $self->{pbot}->{factoidcmds}->factfind($from, $nick, $user, $host, quotemeta $original_keyword); + + # found factfind matches + if($matches !~ m/^No factoids/) { + return "No such factoid '$original_keyword'; found $matches"; + } + + # otherwise find levenshtein closest matches from all channels + $matches = $self->factoids->levenshtein_matches('.*', lc $original_keyword); # don't say anything if nothing similiar was found return undef if $matches eq 'none'; diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index c42c2f13..876df5f0 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,8 +13,8 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 391, - BUILD_DATE => "2012-11-02", + BUILD_REVISION => 392, + BUILD_DATE => "2012-11-04", }; 1;