2010-03-22 08:33:44 +01:00
|
|
|
# File: BotAdminCommands.pm
|
2010-03-24 07:47:40 +01:00
|
|
|
# Author: pragma_
|
2010-03-22 08:33:44 +01:00
|
|
|
#
|
|
|
|
# Purpose: Administrative command subroutines.
|
|
|
|
|
2017-03-05 22:33:31 +01:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2010-03-22 08:33:44 +01:00
|
|
|
package PBot::BotAdminCommands;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
2019-07-11 03:40:53 +02:00
|
|
|
use feature 'unicode_strings';
|
|
|
|
|
2017-08-06 06:38:46 +02:00
|
|
|
use feature 'switch';
|
|
|
|
no if $] >= 5.018, warnings => "experimental::smartmatch";
|
|
|
|
|
2010-03-22 08:33:44 +01:00
|
|
|
use Carp ();
|
|
|
|
|
|
|
|
sub new {
|
2019-05-28 18:19:42 +02:00
|
|
|
if (ref($_[1]) eq 'HASH') {
|
2010-03-22 08:33:44 +01:00
|
|
|
Carp::croak("Options to BotAdminCommands should be key/value pairs, not hash reference");
|
|
|
|
}
|
|
|
|
|
|
|
|
my ($class, %conf) = @_;
|
|
|
|
|
|
|
|
my $self = bless {}, $class;
|
|
|
|
$self->initialize(%conf);
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub initialize {
|
|
|
|
my ($self, %conf) = @_;
|
|
|
|
|
|
|
|
my $pbot = delete $conf{pbot};
|
2019-05-28 18:19:42 +02:00
|
|
|
if (not defined $pbot) {
|
2010-03-22 08:33:44 +01:00
|
|
|
Carp::croak("Missing pbot reference to BotAdminCommands");
|
|
|
|
}
|
|
|
|
|
|
|
|
$self->{pbot} = $pbot;
|
2019-06-26 18:34:19 +02:00
|
|
|
|
2014-05-18 22:09:05 +02:00
|
|
|
$pbot->{commands}->register(sub { return $self->login(@_) }, "login", 0);
|
|
|
|
$pbot->{commands}->register(sub { return $self->logout(@_) }, "logout", 0);
|
2018-02-22 03:43:15 +01:00
|
|
|
$pbot->{commands}->register(sub { return $self->in_channel(@_) }, "in", 0);
|
2015-07-13 11:47:30 +02:00
|
|
|
$pbot->{commands}->register(sub { return $self->join_channel(@_) }, "join", 40);
|
|
|
|
$pbot->{commands}->register(sub { return $self->part_channel(@_) }, "part", 40);
|
|
|
|
$pbot->{commands}->register(sub { return $self->ack_die(@_) }, "die", 90);
|
2014-05-18 22:09:05 +02:00
|
|
|
$pbot->{commands}->register(sub { return $self->adminadd(@_) }, "adminadd", 60);
|
|
|
|
$pbot->{commands}->register(sub { return $self->adminrem(@_) }, "adminrem", 60);
|
|
|
|
$pbot->{commands}->register(sub { return $self->adminset(@_) }, "adminset", 60);
|
|
|
|
$pbot->{commands}->register(sub { return $self->adminunset(@_) }, "adminunset", 60);
|
2015-07-13 11:47:30 +02:00
|
|
|
$pbot->{commands}->register(sub { return $self->sl(@_) }, "sl", 90);
|
|
|
|
$pbot->{commands}->register(sub { return $self->export(@_) }, "export", 90);
|
2017-08-06 06:38:46 +02:00
|
|
|
$pbot->{commands}->register(sub { return $self->reload(@_) }, "reload", 90);
|
2017-08-18 09:53:12 +02:00
|
|
|
$pbot->{commands}->register(sub { return $self->evalcmd(@_) }, "eval", 99);
|
2011-02-10 09:40:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub sl {
|
|
|
|
my $self = shift;
|
|
|
|
my ($from, $nick, $user, $host, $arguments) = @_;
|
|
|
|
|
2019-12-29 08:04:41 +01:00
|
|
|
if (not length $arguments) {
|
|
|
|
return "Usage: sl <ircd command>";
|
|
|
|
}
|
|
|
|
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{conn}->sl($arguments);
|
2017-08-03 23:13:29 +02:00
|
|
|
return "";
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
2018-02-22 03:41:56 +01:00
|
|
|
sub in_channel {
|
2018-02-22 02:21:38 +01:00
|
|
|
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
|
|
|
|
|
2018-02-22 03:41:56 +01:00
|
|
|
my $usage = "Usage: in <channel> <command>";
|
2018-02-22 02:21:38 +01:00
|
|
|
|
|
|
|
if (not $arguments) {
|
|
|
|
return $usage;
|
|
|
|
}
|
|
|
|
|
2018-08-09 02:38:57 +02:00
|
|
|
my ($channel, $command) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
2018-02-22 02:21:38 +01:00
|
|
|
return $usage if not defined $channel or not defined $command;
|
|
|
|
|
2018-02-22 03:41:56 +01:00
|
|
|
$stuff->{admin_channel_override} = $channel;
|
2018-02-22 02:21:38 +01:00
|
|
|
$stuff->{command} = $command;
|
|
|
|
return $self->{pbot}->{interpreter}->interpret($stuff);
|
|
|
|
}
|
|
|
|
|
2010-03-22 08:33:44 +01:00
|
|
|
sub login {
|
|
|
|
my $self = shift;
|
|
|
|
my ($from, $nick, $user, $host, $arguments) = @_;
|
2017-11-03 20:27:59 +01:00
|
|
|
my $channel = $from;
|
2010-03-22 08:33:44 +01:00
|
|
|
|
2017-11-03 20:27:59 +01:00
|
|
|
if (not $arguments) {
|
|
|
|
return "Usage: login [channel] password";
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
2017-11-03 20:27:59 +01:00
|
|
|
if ($arguments =~ m/^([^ ]+)\s+(.+)/) {
|
|
|
|
$channel = $1;
|
|
|
|
$arguments = $2;
|
|
|
|
}
|
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if ($self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host")) {
|
2017-11-03 20:27:59 +01:00
|
|
|
return "/msg $nick You are already logged into channel $channel.";
|
|
|
|
}
|
|
|
|
|
|
|
|
my $result = $self->{pbot}->{admins}->login($channel, "$nick!$user\@$host", $arguments);
|
2010-03-22 08:33:44 +01:00
|
|
|
return "/msg $nick $result";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub logout {
|
|
|
|
my $self = shift;
|
|
|
|
my ($from, $nick, $user, $host, $arguments) = @_;
|
2019-05-28 18:19:42 +02:00
|
|
|
return "/msg $nick Uh, you aren't logged into channel $from." if (not $self->{pbot}->{admins}->loggedin($from, "$nick!$user\@$host"));
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{admins}->logout($from, "$nick!$user\@$host");
|
2010-03-22 08:33:44 +01:00
|
|
|
return "/msg $nick Good-bye, $nick.";
|
|
|
|
}
|
|
|
|
|
2010-08-15 10:25:35 +02:00
|
|
|
sub adminadd {
|
2010-03-22 08:33:44 +01:00
|
|
|
my $self = shift;
|
2018-08-09 02:38:57 +02:00
|
|
|
my ($from, $nick, $user, $host, $arguments, $stuff) = @_;
|
2010-03-29 14:30:35 +02:00
|
|
|
|
2018-08-09 02:38:57 +02:00
|
|
|
my ($name, $channel, $hostmask, $level, $password) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 5);
|
2010-03-29 14:30:35 +02:00
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if (not defined $name or not defined $channel or not defined $hostmask or not defined $level
|
2010-03-29 14:30:35 +02:00
|
|
|
or not defined $password) {
|
2015-07-10 08:25:31 +02:00
|
|
|
return "/msg $nick Usage: adminadd <name> <channel> <hostmask> <level> <password>";
|
2010-03-29 14:30:35 +02:00
|
|
|
}
|
|
|
|
|
2015-07-10 08:25:31 +02:00
|
|
|
$channel = '.*' if lc $channel eq 'global';
|
|
|
|
|
2017-10-15 19:56:51 +02:00
|
|
|
my $admin = $self->{pbot}->{admins}->find_admin($from, "$nick!$user\@$host");
|
|
|
|
|
|
|
|
if (not $admin) {
|
|
|
|
return "You are not an admin in $from.\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($admin->{level} < 90 and $level > 60) {
|
|
|
|
return "You may not set admin level higher than 60.\n";
|
|
|
|
}
|
|
|
|
|
2010-03-29 14:30:35 +02:00
|
|
|
$self->{pbot}->{admins}->add_admin($name, $channel, $hostmask, $level, $password);
|
|
|
|
return "Admin added.";
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
2010-08-15 10:25:35 +02:00
|
|
|
sub adminrem {
|
2010-03-22 08:33:44 +01:00
|
|
|
my $self = shift;
|
2018-08-09 02:38:57 +02:00
|
|
|
my ($from, $nick, $user, $host, $arguments, $stuff) = @_;
|
2010-03-29 14:30:35 +02:00
|
|
|
|
2018-08-09 02:38:57 +02:00
|
|
|
my ($channel, $hostmask) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
2010-03-29 14:30:35 +02:00
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if (not defined $channel or not defined $hostmask) {
|
2015-07-10 08:25:31 +02:00
|
|
|
return "/msg $nick Usage: adminrem <channel> <hostmask/name>";
|
|
|
|
}
|
|
|
|
|
|
|
|
$channel = lc $channel;
|
|
|
|
$hostmask = lc $hostmask;
|
|
|
|
|
|
|
|
$channel = '.*' if $channel eq 'global';
|
|
|
|
|
|
|
|
if (exists $self->{pbot}->{admins}->{admins}->hash->{$channel}) {
|
|
|
|
if (not exists $self->{pbot}->{admins}->{admins}->hash->{$channel}->{$hostmask}) {
|
2017-04-11 04:55:52 +02:00
|
|
|
foreach my $mask (keys %{ $self->{pbot}->{admins}->{admins}->hash->{$channel} }) {
|
2015-07-10 08:25:31 +02:00
|
|
|
if ($self->{pbot}->{admins}->{admins}->hash->{$channel}->{$mask}->{name} eq $hostmask) {
|
|
|
|
$hostmask = $mask;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-03-29 14:30:35 +02:00
|
|
|
}
|
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if ($self->{pbot}->{admins}->remove_admin($channel, $hostmask)) {
|
2010-03-29 14:30:35 +02:00
|
|
|
return "Admin removed.";
|
|
|
|
} else {
|
|
|
|
return "No such admin found.";
|
|
|
|
}
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
2010-08-15 10:25:35 +02:00
|
|
|
sub adminset {
|
|
|
|
my $self = shift;
|
2018-08-09 02:38:57 +02:00
|
|
|
my ($from, $nick, $user, $host, $arguments, $stuff) = @_;
|
|
|
|
my ($channel, $hostmask, $key, $value) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 4);
|
2010-08-15 10:25:35 +02:00
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if (not defined $channel or not defined $hostmask) {
|
2015-07-13 11:47:30 +02:00
|
|
|
return "Usage: adminset <channel> <hostmask/name> [key] [value]";
|
2015-07-10 08:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$channel = lc $channel;
|
|
|
|
$hostmask = lc $hostmask;
|
|
|
|
|
|
|
|
$channel = '.*' if $channel eq 'global';
|
|
|
|
|
|
|
|
if (exists $self->{pbot}->{admins}->{admins}->hash->{$channel}) {
|
|
|
|
if (not exists $self->{pbot}->{admins}->{admins}->hash->{$channel}->{$hostmask}) {
|
2017-04-11 04:55:52 +02:00
|
|
|
foreach my $mask (keys %{ $self->{pbot}->{admins}->{admins}->hash->{$channel} }) {
|
2015-07-10 08:25:31 +02:00
|
|
|
if ($self->{pbot}->{admins}->{admins}->hash->{$channel}->{$mask}->{name} eq $hostmask) {
|
|
|
|
$hostmask = $mask;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-15 10:25:35 +02:00
|
|
|
}
|
|
|
|
|
2017-10-15 19:56:51 +02:00
|
|
|
my $admin = $self->{pbot}->{admins}->find_admin($from, "$nick!$user\@$host");
|
|
|
|
my $target = $self->{pbot}->{admins}->find_admin($channel, $hostmask);
|
|
|
|
|
|
|
|
if (not $admin) {
|
|
|
|
return "You are not an admin in $from.";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (not $target) {
|
|
|
|
return "There is no admin $hostmask in channel $channel.";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($key eq 'level' && $admin->{level} < 90 and $value > 60) {
|
|
|
|
return "You may not set admin level higher than 60.\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($target->{level} > $admin->{level}) {
|
|
|
|
return "You may not modify admins higher in level than you.";
|
|
|
|
}
|
|
|
|
|
2014-05-18 22:09:05 +02:00
|
|
|
return $self->{pbot}->{admins}->{admins}->set($channel, $hostmask, $key, $value);
|
2010-08-15 10:25:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub adminunset {
|
|
|
|
my $self = shift;
|
2018-08-09 02:38:57 +02:00
|
|
|
my ($from, $nick, $user, $host, $arguments, $stuff) = @_;
|
|
|
|
my ($channel, $hostmask, $key) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3);
|
2010-08-15 10:25:35 +02:00
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if (not defined $channel or not defined $hostmask) {
|
2015-07-10 08:25:31 +02:00
|
|
|
return "Usage: adminunset <channel> <hostmask/name> <key>";
|
|
|
|
}
|
|
|
|
|
|
|
|
$channel = lc $channel;
|
|
|
|
$hostmask = lc $hostmask;
|
|
|
|
|
|
|
|
$channel = '.*' if $channel eq 'global';
|
|
|
|
|
|
|
|
if (exists $self->{pbot}->{admins}->{admins}->hash->{$channel}) {
|
|
|
|
if (not exists $self->{pbot}->{admins}->{admins}->hash->{$channel}->{$hostmask}) {
|
2017-04-11 04:55:52 +02:00
|
|
|
foreach my $mask (keys %{ $self->{pbot}->{admins}->{admins}->hash->{$channel} }) {
|
2015-07-10 08:25:31 +02:00
|
|
|
if ($self->{pbot}->{admins}->{admins}->hash->{$channel}->{$mask}->{name} eq $hostmask) {
|
|
|
|
$hostmask = $mask;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-15 10:25:35 +02:00
|
|
|
}
|
|
|
|
|
2014-05-18 22:09:05 +02:00
|
|
|
return $self->{pbot}->{admins}->{admins}->unset($channel, $hostmask, $key);
|
2010-08-15 10:25:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-22 08:33:44 +01:00
|
|
|
sub join_channel {
|
|
|
|
my $self = shift;
|
|
|
|
my ($from, $nick, $user, $host, $arguments) = @_;
|
|
|
|
|
2018-08-09 02:38:57 +02:00
|
|
|
foreach my $channel (split /[\s+,]/, $arguments) {
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{logger}->log("$nick!$user\@$host made me join $channel\n");
|
2014-12-18 09:46:13 +01:00
|
|
|
$self->{pbot}->{chanops}->join_channel($channel);
|
2014-05-13 12:15:52 +02:00
|
|
|
}
|
|
|
|
|
2010-04-02 19:33:18 +02:00
|
|
|
return "/msg $nick Joining $arguments";
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub part_channel {
|
|
|
|
my $self = shift;
|
|
|
|
my ($from, $nick, $user, $host, $arguments) = @_;
|
|
|
|
|
2014-05-13 12:15:52 +02:00
|
|
|
$arguments = $from if not $arguments;
|
|
|
|
|
2018-08-09 02:38:57 +02:00
|
|
|
foreach my $channel (split /[\s+,]/, $arguments) {
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{logger}->log("$nick!$user\@$host made me part $channel\n");
|
2014-12-18 09:46:13 +01:00
|
|
|
$self->{pbot}->{chanops}->part_channel($channel);
|
2014-05-13 12:15:52 +02:00
|
|
|
}
|
|
|
|
|
2010-04-02 19:33:18 +02:00
|
|
|
return "/msg $nick Parting $arguments";
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub ack_die {
|
|
|
|
my $self = shift;
|
|
|
|
my ($from, $nick, $user, $host, $arguments) = @_;
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{logger}->log("$nick!$user\@$host made me exit.\n");
|
2014-05-17 00:11:31 +02:00
|
|
|
$self->{pbot}->atexit();
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{conn}->privmsg($from, "Good-bye.") if defined $from;
|
|
|
|
$self->{pbot}->{conn}->quit("Departure requested.");
|
2010-03-22 08:33:44 +01:00
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub export {
|
2012-08-24 00:50:07 +02:00
|
|
|
my $self = shift;
|
2010-03-22 08:33:44 +01:00
|
|
|
my ($from, $nick, $user, $host, $arguments) = @_;
|
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if (not defined $arguments) {
|
2015-09-08 20:42:43 +02:00
|
|
|
return "/msg $nick Usage: export <modules|factoids|admins>";
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if ($arguments =~ /^modules$/i) {
|
2010-03-22 08:33:44 +01:00
|
|
|
return "/msg $nick Coming soon.";
|
|
|
|
}
|
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if ($arguments =~ /^factoids$/i) {
|
2019-06-26 18:34:19 +02:00
|
|
|
return $self->{pbot}->{factoids}->export_factoids;
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
2019-05-28 18:19:42 +02:00
|
|
|
if ($arguments =~ /^admins$/i) {
|
2010-03-22 08:33:44 +01:00
|
|
|
return "/msg $nick Coming soon.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-18 09:53:12 +02:00
|
|
|
sub evalcmd {
|
|
|
|
my ($self, $from, $nick, $user, $host, $arguments) = @_;
|
|
|
|
|
|
|
|
$self->{pbot}->{logger}->log("[$from] $nick!$user\@$host Evaluating [$arguments]\n");
|
|
|
|
|
|
|
|
my $ret;
|
|
|
|
my $result = eval $arguments;
|
|
|
|
if ($@) {
|
|
|
|
if (length $result) {
|
|
|
|
$ret .= "[Error: $@] ";
|
|
|
|
} else {
|
|
|
|
$ret .= "Error: $@";
|
|
|
|
}
|
|
|
|
$ret =~ s/ at \(eval \d+\) line 1.//;
|
|
|
|
}
|
2017-09-02 09:14:13 +02:00
|
|
|
return "/say $ret $result";
|
2017-08-18 09:53:12 +02:00
|
|
|
}
|
|
|
|
|
2017-08-06 06:38:46 +02:00
|
|
|
sub reload {
|
|
|
|
my $self = shift;
|
|
|
|
my ($from, $nick, $user, $host, $arguments) = @_;
|
|
|
|
|
2019-08-25 03:18:07 +02:00
|
|
|
my %reloadables = (
|
|
|
|
'blacklist' => sub {
|
2017-08-06 06:38:46 +02:00
|
|
|
$self->{pbot}->{blacklist}->clear_blacklist;
|
|
|
|
$self->{pbot}->{blacklist}->load_blacklist;
|
|
|
|
return "Blacklist reloaded.";
|
2019-08-25 03:18:07 +02:00
|
|
|
},
|
2017-08-06 06:38:46 +02:00
|
|
|
|
2019-08-25 03:18:07 +02:00
|
|
|
'whitelist' => sub {
|
2017-08-06 06:38:46 +02:00
|
|
|
$self->{pbot}->{antiflood}->{whitelist}->clear;
|
|
|
|
$self->{pbot}->{antiflood}->{whitelist}->load;
|
|
|
|
return "Whitelist reloaded.";
|
2019-08-25 03:18:07 +02:00
|
|
|
},
|
2017-08-06 06:38:46 +02:00
|
|
|
|
2019-08-25 03:18:07 +02:00
|
|
|
'ignores' => sub {
|
2017-08-06 06:38:46 +02:00
|
|
|
$self->{pbot}->{ignorelist}->clear_ignores;
|
|
|
|
$self->{pbot}->{ignorelist}->load_ignores;
|
|
|
|
return "Ignore list reloaded.";
|
2019-08-25 03:18:07 +02:00
|
|
|
},
|
2017-08-06 06:38:46 +02:00
|
|
|
|
2019-08-25 03:18:07 +02:00
|
|
|
'admins' => sub {
|
2017-08-06 06:38:46 +02:00
|
|
|
$self->{pbot}->{admins}->{admins}->clear;
|
|
|
|
$self->{pbot}->{admins}->load_admins;
|
|
|
|
return "Admins reloaded.";
|
2019-08-25 03:18:07 +02:00
|
|
|
},
|
2017-08-06 06:38:46 +02:00
|
|
|
|
2019-08-25 03:18:07 +02:00
|
|
|
'channels' => sub {
|
2017-08-06 06:38:46 +02:00
|
|
|
$self->{pbot}->{channels}->{channels}->clear;
|
|
|
|
$self->{pbot}->{channels}->load_channels;
|
|
|
|
return "Channels reloaded.";
|
2019-08-25 03:18:07 +02:00
|
|
|
},
|
2017-08-06 06:38:46 +02:00
|
|
|
|
2019-08-25 03:18:07 +02:00
|
|
|
'bantimeouts' => sub {
|
2017-08-06 06:38:46 +02:00
|
|
|
$self->{pbot}->{chanops}->{unban_timeout}->clear;
|
|
|
|
$self->{pbot}->{chanops}->{unban_timeout}->load;
|
|
|
|
return "Ban timeouts reloaded.";
|
2019-08-25 03:18:07 +02:00
|
|
|
},
|
2017-08-06 06:38:46 +02:00
|
|
|
|
2019-08-25 03:18:07 +02:00
|
|
|
'mutetimeouts' => sub {
|
2017-08-06 06:38:46 +02:00
|
|
|
$self->{pbot}->{chanops}->{unmute_timeout}->clear;
|
|
|
|
$self->{pbot}->{chanops}->{unmute_timeout}->load;
|
|
|
|
return "Mute timeouts reloaded.";
|
2019-08-25 03:18:07 +02:00
|
|
|
},
|
2017-08-06 06:38:46 +02:00
|
|
|
|
2019-08-25 03:18:07 +02:00
|
|
|
'registry' => sub {
|
2017-08-06 06:38:46 +02:00
|
|
|
$self->{pbot}->{registry}->{registry}->clear;
|
|
|
|
$self->{pbot}->{registry}->load;
|
|
|
|
return "Registry reloaded.";
|
2019-08-25 03:18:07 +02:00
|
|
|
},
|
2017-08-06 06:38:46 +02:00
|
|
|
|
2019-08-25 03:18:07 +02:00
|
|
|
'factoids' => sub {
|
2017-08-06 06:38:46 +02:00
|
|
|
$self->{pbot}->{factoids}->{factoids}->clear;
|
|
|
|
$self->{pbot}->{factoids}->load_factoids;
|
|
|
|
return "Factoids reloaded.";
|
2019-08-25 04:03:08 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
'funcs' => sub {
|
|
|
|
$self->{pbot}->{func_cmd}->init_funcs;
|
|
|
|
return "Funcs reloaded.";
|
2017-08-06 06:38:46 +02:00
|
|
|
}
|
2019-08-25 03:18:07 +02:00
|
|
|
);
|
2017-08-06 06:38:46 +02:00
|
|
|
|
2019-08-25 03:18:07 +02:00
|
|
|
if (not length $arguments or not exists $reloadables{$arguments}) {
|
2019-08-25 04:03:08 +02:00
|
|
|
my $usage = 'Usage: reload <';
|
2019-08-25 03:18:07 +02:00
|
|
|
$usage .= join '|', sort keys %reloadables;
|
|
|
|
$usage .= '>';
|
|
|
|
return $usage;
|
2017-08-06 06:38:46 +02:00
|
|
|
}
|
2019-08-25 03:18:07 +02:00
|
|
|
|
|
|
|
return $reloadables{$arguments}();
|
2017-08-06 06:38:46 +02:00
|
|
|
}
|
|
|
|
|
2010-03-22 08:33:44 +01:00
|
|
|
1;
|