mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-10 20:12:35 +01:00
Allow <foo> is <bar> to pass through to other interpeters if factoid already exists
This commit is contained in:
parent
001cbc86e5
commit
1330bfcff5
@ -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.";
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user