mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 02:49:49 +01:00
Factoids: add default options for named parameters
This commit is contained in:
parent
75a31458b0
commit
f0181c7a69
@ -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);
|
||||
|
||||
|
@ -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++) {
|
||||
|
Loading…
Reference in New Issue
Block a user