mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 11:12:42 +01:00
Triggering non-existent factoids now attempts to factfind (for keywords and text) before trying a levenshtein closest match (of keywords)
This commit is contained in:
parent
b8d2d0797e
commit
39a38b58f8
@ -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);
|
||||
|
@ -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';
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user