FuncCommand: clarify a comment

This commit is contained in:
Pragmatic Software 2019-08-25 00:10:45 -07:00
parent 3034e7118f
commit 78082792e5
1 changed files with 25 additions and 23 deletions

View File

@ -46,6 +46,8 @@ sub initialize {
$self->init_funcs;
}
# this is a subroutine so PBot::BotAdminCommands::reload() can reload
# the funcs without requiring a bot restart.
sub init_funcs {
my ($self) = @_;
@ -78,6 +80,29 @@ sub init_funcs {
};
}
sub do_func {
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
my $func = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist});
if (not defined $func) {
return "Usage: func <keyword> [arguments]";
}
if (not exists $self->{funcs}->{$func}) {
return "[No such func '$func']";
}
my @params;
while (my $param = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist})) {
push @params, $param;
}
my $result = $self->{funcs}->{$func}->{subref}->(@params);
$result =~ s/\x1/1/g;
return $result;
}
sub func_help {
my ($self, $func) = @_;
@ -171,27 +196,4 @@ sub func_sed {
}
use warnings;
sub do_func {
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
my $func = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist});
if (not defined $func) {
return "Usage: func <keyword> [arguments]";
}
if (not exists $self->{funcs}->{$func}) {
return "[No such func '$func']";
}
my @params;
while (my $param = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist})) {
push @params, $param;
}
my $result = $self->{funcs}->{$func}->{subref}->(@params);
$result =~ s/\x1/1/g;
return $result;
}
1;