3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-01 17:16:39 +02:00

Allow <foo> is <bar> to pass through to other interpeters if factoid already exists

This commit is contained in:
Pragmatic Software 2010-04-18 07:34:01 +00:00
parent 001cbc86e5
commit 1330bfcff5
3 changed files with 7 additions and 5 deletions

View File

@ -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.";
}

View File

@ -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;
}

View File

@ -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 {