diff --git a/PBot/FactoidCommands.pm b/PBot/FactoidCommands.pm index 9ad8bae3..3fb8c226 100644 --- a/PBot/FactoidCommands.pm +++ b/PBot/FactoidCommands.pm @@ -236,6 +236,7 @@ sub add_text { if(exists $factoids->{$keyword}) { $self->{pbot}->logger->log("$nick!$user\@$host attempt to overwrite $keyword\n"); + return undef; return "/msg $nick $keyword already exists."; } diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 93b2141d..c5e0aacf 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -244,7 +244,7 @@ sub find_factoid { sub levenshtein_matches { my ($self, $keyword) = @_; my $comma = ''; - my $result = "No such factoid '$keyword'; similiar matches: "; + my $result = "I don't know about '$keyword'; did you mean "; foreach my $command (sort keys %{ $self->factoids }) { next if exists $self->factoids->{$command}{regex}; @@ -262,7 +262,9 @@ sub levenshtein_matches { } } - $result .= "none." if $comma eq ''; + $result =~ s/(.*), /$1 or /; + $result =~ s/$/?/; + $result = undef if $comma eq ''; return $result; } diff --git a/PBot/Interpreter.pm b/PBot/Interpreter.pm index ffd43d0b..baf8ef13 100644 --- a/PBot/Interpreter.pm +++ b/PBot/Interpreter.pm @@ -109,7 +109,6 @@ sub process_line { if(defined $result && length $result > 0) { my $len = length $result; if($len > $pbot->max_msg_len) { - print "result: [$result]\n"; my $link = paste_codepad("[$from] <$nick> $text\n\n$result"); my $trunc = "... truncated; see $link for full text."; $pbot->logger->log("Message truncated -- pasted to $link\n"); @@ -179,8 +178,8 @@ sub interpret { } elsif($command =~ /^([^ ]+)\s+is\s+also\s+(.*)$/) { ($keyword, $arguments) = ("change", "$1 s,\$, ; $2,"); } elsif($command =~ /^([^ ]+)\s+is\s+(.*)$/) { - ($keyword, $arguments) = ("add", join(' ', $1, $2)) unless exists ${ $pbot->factoids }{$1}; - ($keyword, $arguments) = ($1, "is $2") if exists ${ $pbot->factoids }{$1}; + ($keyword, $arguments) = ("add", join(' ', $1, $2)) unless exists ${ $pbot->factoids }{factoids}{$1}; + ($keyword, $arguments) = ($1, "is $2") if exists ${ $pbot->factoids }{factoids}{$1}; } elsif($command =~ /^(.*?)\s+(.*)$/) { ($keyword, $arguments) = ($1, $2); } else {