3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 10:59:29 +01:00

BotAdminCommands: automate reload usage message

This commit is contained in:
Pragmatic Software 2019-08-24 18:18:07 -07:00
parent e06f484a6e
commit 7f1173b9d6

View File

@ -327,65 +327,70 @@ sub reload {
my $self = shift; my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
given ($arguments) { my %reloadables = (
when ("blacklist") { 'blacklist' => sub {
$self->{pbot}->{blacklist}->clear_blacklist; $self->{pbot}->{blacklist}->clear_blacklist;
$self->{pbot}->{blacklist}->load_blacklist; $self->{pbot}->{blacklist}->load_blacklist;
return "Blacklist reloaded."; return "Blacklist reloaded.";
} },
when ("whitelist") { 'whitelist' => sub {
$self->{pbot}->{antiflood}->{whitelist}->clear; $self->{pbot}->{antiflood}->{whitelist}->clear;
$self->{pbot}->{antiflood}->{whitelist}->load; $self->{pbot}->{antiflood}->{whitelist}->load;
return "Whitelist reloaded."; return "Whitelist reloaded.";
} },
when ("ignores") { 'ignores' => sub {
$self->{pbot}->{ignorelist}->clear_ignores; $self->{pbot}->{ignorelist}->clear_ignores;
$self->{pbot}->{ignorelist}->load_ignores; $self->{pbot}->{ignorelist}->load_ignores;
return "Ignore list reloaded."; return "Ignore list reloaded.";
} },
when ("admins") { 'admins' => sub {
$self->{pbot}->{admins}->{admins}->clear; $self->{pbot}->{admins}->{admins}->clear;
$self->{pbot}->{admins}->load_admins; $self->{pbot}->{admins}->load_admins;
return "Admins reloaded."; return "Admins reloaded.";
} },
when ("channels") { 'channels' => sub {
$self->{pbot}->{channels}->{channels}->clear; $self->{pbot}->{channels}->{channels}->clear;
$self->{pbot}->{channels}->load_channels; $self->{pbot}->{channels}->load_channels;
return "Channels reloaded."; return "Channels reloaded.";
} },
when ("bantimeouts") { 'bantimeouts' => sub {
$self->{pbot}->{chanops}->{unban_timeout}->clear; $self->{pbot}->{chanops}->{unban_timeout}->clear;
$self->{pbot}->{chanops}->{unban_timeout}->load; $self->{pbot}->{chanops}->{unban_timeout}->load;
return "Ban timeouts reloaded."; return "Ban timeouts reloaded.";
} },
when ("mutetimeouts") { 'mutetimeouts' => sub {
$self->{pbot}->{chanops}->{unmute_timeout}->clear; $self->{pbot}->{chanops}->{unmute_timeout}->clear;
$self->{pbot}->{chanops}->{unmute_timeout}->load; $self->{pbot}->{chanops}->{unmute_timeout}->load;
return "Mute timeouts reloaded."; return "Mute timeouts reloaded.";
} },
when ("registry") { 'registry' => sub {
$self->{pbot}->{registry}->{registry}->clear; $self->{pbot}->{registry}->{registry}->clear;
$self->{pbot}->{registry}->load; $self->{pbot}->{registry}->load;
return "Registry reloaded."; return "Registry reloaded.";
} },
when ("factoids") { 'factoids' => sub {
$self->{pbot}->{factoids}->{factoids}->clear; $self->{pbot}->{factoids}->{factoids}->clear;
$self->{pbot}->{factoids}->load_factoids; $self->{pbot}->{factoids}->load_factoids;
return "Factoids reloaded."; return "Factoids reloaded.";
} }
);
default { if (not length $arguments or not exists $reloadables{$arguments}) {
return "Usage: reload <blacklist|whitelist|ignores|admins|channels|bantimeouts|mutetimeouts|registry|factoids>"; my $usage = 'Usage: refload <';
} $usage .= join '|', sort keys %reloadables;
$usage .= '>';
return $usage;
} }
return $reloadables{$arguments}();
} }
1; 1;