diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 21ca85be..ce3f1b26 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -330,14 +330,11 @@ sub find_factoid { } if (not $opts{exact_channel}) { - my $factoids = $self->{factoids}->get_all_by_trigger($keyword); - - foreach my $factoid (@$factoids) { + foreach my $factoid ($self->{factoids}->get(index2 => $keyword, index1 => undef, action => undef)) { $channel = $factoid->{index1}; - $trigger = $factoid->{index2}; - $action = $factoid->{action}; + $trigger = $keyword; - if ($opts{find_alias} && $action =~ m{^/call\s+(.*)$}ms) { + if ($opts{find_alias} && $factoid->{action} =~ m{^/call\s+(.*)$}ms) { goto CHECK_ALIAS; } @@ -797,7 +794,7 @@ sub interpreter { # if multiple channels have this keyword, then ask user to disambiguate if (@chanlist> 1) { return undef if $stuff->{referenced}; - return $ref_from . "Ambiguous keyword '$original_keyword' exists in multiple channels (use 'fact $original_keyword' to choose one): " . join(' ,', @chanlist); + return $ref_from . "Ambiguous keyword '$original_keyword' exists in multiple channels (use 'fact $original_keyword' to choose one): " . join(', ', @chanlist); } # if there's just one other channel that has this keyword, trigger that instance diff --git a/PBot/FactoidsSQLite.pm b/PBot/FactoidsSQLite.pm index 62c5a6c4..adad42a0 100644 --- a/PBot/FactoidsSQLite.pm +++ b/PBot/FactoidsSQLite.pm @@ -25,23 +25,6 @@ sub new { return $self; } -sub get_all_by_trigger { - my ($self, $index2) = @_; - - my $data = eval { - my $sth = $self->{dbh}->prepare('SELECT index1, index2, action FROM Stuff WHERE index2 = ?'); - $sth->execute($index2); - return $sth->fetchall_arrayref({}); - }; - - if ($@) { - $self->{pbot}->{logger}->log("Error in get_all_by_trigger: $@\n"); - return undef; - } - - return $data; -} - sub get_regex_by_channel { my ($self, $channel) = @_;