diff --git a/PBot/FactoidCommands.pm b/PBot/FactoidCommands.pm index 7b382ddf..45bef0e2 100644 --- a/PBot/FactoidCommands.pm +++ b/PBot/FactoidCommands.pm @@ -170,6 +170,14 @@ sub log_factoid { sub find_factoid_with_optional_channel { my ($self, $from, $arguments, $command, %opts) = @_; + my %default_opts = ( + usage => undef, + explicit => 0, + exact_channel => 0 + ); + + %opts = (%default_opts, %opts); + my $arglist = $self->{pbot}->{interpreter}->make_args($arguments); my ($from_chan, $from_trigger, $remaining_args) = $self->{pbot}->{interpreter}->split_args($arglist, 3); diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index fbf8150e..7f315143 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -271,6 +271,15 @@ sub export_factoids { sub find_factoid { my ($self, $from, $keyword, %opts) = @_; + my %default_opts = ( + arguments => '', + exact_channel => 0, + exact_trigger => 0, + find_alias => 0 + ); + + %opts = (%default_opts, %opts); + my $debug = 0; if ($debug) { @@ -279,13 +288,13 @@ sub find_factoid { $self->{pbot}->{logger}->log("find_factiod: from: $from, kw: $keyword, opts: $dump\n"); } - my $arguments = exists $opts{arguments} ? $opts{arguments} : ""; - $from = '.*' if not defined $from or $from !~ /^#/; $from = lc $from; $self->{pbot}->{logger}->log("from: $from\n") if $debug; + my $arguments = $opts{arguments}; + my @result = eval { my @results; for (my $depth = 0; $depth < 5; $depth++) {