3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 22:09:26 +01:00

Factoids: /msg caller for unknown command instead of silently disregarding

This commit is contained in:
Pragmatic Software 2020-03-04 09:56:22 -08:00
parent 48361191bd
commit e28d664cd5

View File

@ -812,9 +812,6 @@ sub interpreter {
# otherwise keyword hasn't been found, display similiar matches for all channels # otherwise keyword hasn't been found, display similiar matches for all channels
else { else {
# if a non-nick argument was supplied, e.g., a sentence using the bot's nick, don't say anything
return undef if length $stuff->{arguments} and not $self->{pbot}->{nicklist}->is_present($stuff->{from}, $stuff->{arguments});
my $namespace = $strictnamespace ? $stuff->{from} : '.*'; my $namespace = $strictnamespace ? $stuff->{from} : '.*';
$namespace = '.*' if $namespace !~ /^#/; $namespace = '.*' if $namespace !~ /^#/;
@ -832,12 +829,20 @@ sub interpreter {
# otherwise find levenshtein closest matches # otherwise find levenshtein closest matches
$matches = $self->{factoids}->levenshtein_matches($namespace, lc $original_keyword, 0.50, $strictnamespace); $matches = $self->{factoids}->levenshtein_matches($namespace, lc $original_keyword, 0.50, $strictnamespace);
# don't say anything if nothing similiar was found # if a non-nick argument was supplied, e.g., a sentence using the bot's nick, /msg the error to the caller
return undef if $matches eq 'none'; if (length $stuff->{arguments} and not $self->{pbot}->{nicklist}->is_present($stuff->{from}, $stuff->{arguments})) {
return undef if $stuff->{referenced}; $stuff->{send_msg_to_caller} = 1;
}
# /msg the caller if nothing similiar was found
$stuff->{send_msg_to_caller} = 1 if $matches eq 'none';
$stuff->{send_msg_to_caller} = 1 if $stuff->{referenced};
my $msg_caller = '';
$msg_caller = "/msg $stuff->{nick} " if $stuff->{send_msg_to_caller};
my $ref_from = $stuff->{ref_from} ? "[$stuff->{ref_from}] " : ""; my $ref_from = $stuff->{ref_from} ? "[$stuff->{ref_from}] " : "";
return $ref_from . "No such factoid '$original_keyword'; did you mean $matches?"; return $msg_caller . $ref_from . "No such factoid '$original_keyword'; did you mean $matches?";
} }
} }