3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-05 02:48:50 +02:00

FuncCommand: clarify a comment

This commit is contained in:
Pragmatic Software 2019-08-25 00:10:45 -07:00
parent 3034e7118f
commit 78082792e5

View File

@ -46,6 +46,8 @@ sub initialize {
$self->init_funcs; $self->init_funcs;
} }
# this is a subroutine so PBot::BotAdminCommands::reload() can reload
# the funcs without requiring a bot restart.
sub init_funcs { sub init_funcs {
my ($self) = @_; 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 { sub func_help {
my ($self, $func) = @_; my ($self, $func) = @_;
@ -171,27 +196,4 @@ sub func_sed {
} }
use warnings; 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; 1;