factoids: if unknown keyword is triggered inadvertedly, .e.g. by referencing the bot by name, and the args dont look like a nick then do not spit out the levenshtein matches text

This commit is contained in:
Pragmatic Software 2011-01-30 02:44:56 +00:00
parent 514484a1e6
commit 221a698ecb
2 changed files with 6 additions and 3 deletions

View File

@ -236,6 +236,9 @@ sub interpreter {
return $ref_from . $pbot->factoids->interpreter($fwd_chan, $nick, $user, $host, $count, $fwd_trig, $arguments, undef, "[$fwd_chan] ");
} 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}$/;
# if keyword hasn't been found, display similiar matches for all channels
my $matches = $self->factoids->levenshtein_matches('.*', lc $original_keyword);
@ -337,7 +340,7 @@ sub interpreter {
if(not $result =~ s/\$args/$arguments/gi) {
# factoid doesn't take an argument, so assume argument is a nick if it is a single-word 20 characters or less
# TODO - maintain list of channel nicks and compare against this list to ensure nick exists
if($arguments =~ /^[^ ]{1,20}$/) {
if($arguments =~ /^[^.+-, ]{1,20}$/) {
# might be a nick
if($result =~ /^\/.+? /) {
$result =~ s/^(\/.+?) /$1 $arguments: /;
@ -345,7 +348,7 @@ sub interpreter {
$result =~ s/^/\/say $arguments: $keyword is / unless defined $tonick;
}
} else {
# return undef;
# return "";
}
}
} else {

View File

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