3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 11:12:42 +01:00

Commands: Fix cmdset, cmdunset and help commands

This commit is contained in:
Pragmatic Software 2021-07-21 10:08:07 -07:00
parent 8d0d5bc711
commit d4d9b37e76
2 changed files with 7 additions and 8 deletions

View File

@ -39,7 +39,7 @@ sub cmd_set {
return "Usage: cmdset <command> [key [value]]"; return "Usage: cmdset <command> [key [value]]";
} }
return $self->{metadata}->set($command, $key, $value); return $self->{pbot}->{commands}->{metadata}->set($command, $key, $value);
} }
sub cmd_unset { sub cmd_unset {
@ -51,7 +51,7 @@ sub cmd_unset {
return "Usage: cmdunset <command> <key>"; return "Usage: cmdunset <command> <key>";
} }
return $self->{metadata}->unset($command, $key); return $self->{pbot}->{commands}->{metadata}->unset($command, $key);
} }
1; 1;

View File

@ -24,7 +24,6 @@ sub new {
sub initialize { sub initialize {
my ($self, %conf) = @_; my ($self, %conf) = @_;
$self->{pbot}->{commands}->register(sub { $self->cmd_help(@_) }, 'help'); $self->{pbot}->{commands}->register(sub { $self->cmd_help(@_) }, 'help');
} }
@ -38,13 +37,13 @@ sub cmd_help {
my $keyword = lc $self->{pbot}->{interpreter}->shift_arg($context->{arglist}); my $keyword = lc $self->{pbot}->{interpreter}->shift_arg($context->{arglist});
# check built-in commands first # check built-in commands first
if ($self->exists($keyword)) { if ($self->{pbot}->{commands}->exists($keyword)) {
# check for command metadata # check for command metadata
if ($self->{metadata}->exists($keyword)) { if ($self->{pbot}->{commands}->{metadata}->exists($keyword)) {
my $name = $self->{metadata}->get_key_name($keyword); my $name = $self->{pbot}->{commands}->{metadata}->get_key_name($keyword);
my $requires_cap = $self->{metadata}->get_data($keyword, 'requires_cap'); my $requires_cap = $self->{pbot}->{commands}->{metadata}->get_data($keyword, 'requires_cap');
my $help = $self->{metadata}->get_data($keyword, 'help'); my $help = $self->{pbot}->{commands}->{metadata}->get_data($keyword, 'help');
my $result = "/say $name: "; my $result = "/say $name: ";