3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-30 07:49:38 +01:00

Plugins: add replug command

This commit is contained in:
Pragmatic Software 2019-05-08 21:06:56 -07:00
parent 3c3a96461e
commit 207fcba402

View File

@ -36,9 +36,8 @@ sub initialize {
$self->{pbot}->{commands}->register(sub { $self->load_cmd(@_) }, "plug", 90);
$self->{pbot}->{commands}->register(sub { $self->unload_cmd(@_) }, "unplug", 90);
$self->{pbot}->{commands}->register(sub { $self->reload_cmd(@_) }, "replug", 90);
$self->{pbot}->{commands}->register(sub { $self->list_cmd(@_) }, "pluglist", 0);
$self->autoload(%conf);
}
sub autoload {
@ -119,6 +118,22 @@ sub unload {
}
}
sub reload_cmd {
my ($self, $from, $nick, $user, $host, $arguments) = @_;
if (not length $arguments) {
return "Usage: replug <plugin>";
}
my $unload_result = $self->unload_cmd($from, $nick, $user, $host, $arguments);
my $load_result = $self->load_cmd($from, $nick, $user, $host, $arguments);
my $result = "";
$result .= "$unload_result " if $unload_result =~ m/^Unloaded/;
$result .= $load_result;
return $result;
}
sub load_cmd {
my ($self, $from, $nick, $user, $host, $arguments) = @_;