3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-02-19 23:10:44 +01:00

Rename BotAdmin* to Admin*

This commit is contained in:
Pragmatic Software 2020-01-20 15:25:26 -08:00
parent 83527e4b06
commit fa9bb06606
4 changed files with 25 additions and 34 deletions

View File

@ -1,4 +1,4 @@
# File: BotAdminCommands.pm # File: AdminCommands.pm
# Author: pragma_ # Author: pragma_
# #
# Purpose: Administrative command subroutines. # Purpose: Administrative command subroutines.
@ -7,7 +7,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
package PBot::BotAdminCommands; package PBot::AdminCommands;
use warnings; use warnings;
use strict; use strict;
@ -20,12 +20,8 @@ no if $] >= 5.018, warnings => "experimental::smartmatch";
use Carp (); use Carp ();
sub new { sub new {
if (ref($_[1]) eq 'HASH') { Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref($_[1]) eq 'HASH';
Carp::croak("Options to BotAdminCommands should be key/value pairs, not hash reference");
}
my ($class, %conf) = @_; my ($class, %conf) = @_;
my $self = bless {}, $class; my $self = bless {}, $class;
$self->initialize(%conf); $self->initialize(%conf);
return $self; return $self;
@ -34,27 +30,22 @@ sub new {
sub initialize { sub initialize {
my ($self, %conf) = @_; my ($self, %conf) = @_;
my $pbot = delete $conf{pbot}; $self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
if (not defined $pbot) {
Carp::croak("Missing pbot reference to BotAdminCommands");
}
$self->{pbot} = $pbot; $self->{pbot}->{commands}->register(sub { return $self->login(@_) }, "login", 0);
$self->{pbot}->{commands}->register(sub { return $self->logout(@_) }, "logout", 0);
$pbot->{commands}->register(sub { return $self->login(@_) }, "login", 0); $self->{pbot}->{commands}->register(sub { return $self->in_channel(@_) }, "in", 0);
$pbot->{commands}->register(sub { return $self->logout(@_) }, "logout", 0); $self->{pbot}->{commands}->register(sub { return $self->join_channel(@_) }, "join", 40);
$pbot->{commands}->register(sub { return $self->in_channel(@_) }, "in", 0); $self->{pbot}->{commands}->register(sub { return $self->part_channel(@_) }, "part", 40);
$pbot->{commands}->register(sub { return $self->join_channel(@_) }, "join", 40); $self->{pbot}->{commands}->register(sub { return $self->ack_die(@_) }, "die", 90);
$pbot->{commands}->register(sub { return $self->part_channel(@_) }, "part", 40); $self->{pbot}->{commands}->register(sub { return $self->adminadd(@_) }, "adminadd", 60);
$pbot->{commands}->register(sub { return $self->ack_die(@_) }, "die", 90); $self->{pbot}->{commands}->register(sub { return $self->adminrem(@_) }, "adminrem", 60);
$pbot->{commands}->register(sub { return $self->adminadd(@_) }, "adminadd", 60); $self->{pbot}->{commands}->register(sub { return $self->adminset(@_) }, "adminset", 60);
$pbot->{commands}->register(sub { return $self->adminrem(@_) }, "adminrem", 60); $self->{pbot}->{commands}->register(sub { return $self->adminunset(@_) }, "adminunset", 60);
$pbot->{commands}->register(sub { return $self->adminset(@_) }, "adminset", 60); $self->{pbot}->{commands}->register(sub { return $self->sl(@_) }, "sl", 90);
$pbot->{commands}->register(sub { return $self->adminunset(@_) }, "adminunset", 60); $self->{pbot}->{commands}->register(sub { return $self->export(@_) }, "export", 90);
$pbot->{commands}->register(sub { return $self->sl(@_) }, "sl", 90); $self->{pbot}->{commands}->register(sub { return $self->reload(@_) }, "reload", 90);
$pbot->{commands}->register(sub { return $self->export(@_) }, "export", 90); $self->{pbot}->{commands}->register(sub { return $self->evalcmd(@_) }, "eval", 99);
$pbot->{commands}->register(sub { return $self->reload(@_) }, "reload", 90);
$pbot->{commands}->register(sub { return $self->evalcmd(@_) }, "eval", 99);
} }
sub sl { sub sl {

View File

@ -1,4 +1,4 @@
# File: BotAdmins.pm # File: Admins.pm
# Author: pragma_ # Author: pragma_
# #
# Purpose: Manages list of bot admins and whether they are logged in. # Purpose: Manages list of bot admins and whether they are logged in.
@ -7,7 +7,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
package PBot::BotAdmins; package PBot::Admins;
use warnings; use warnings;
use strict; use strict;
@ -15,7 +15,7 @@ use strict;
use feature 'unicode_strings'; use feature 'unicode_strings';
use PBot::DualIndexHashObject; use PBot::DualIndexHashObject;
use PBot::BotAdminCommands; use PBot::AdminCommands;
use Carp (); use Carp ();
@ -31,7 +31,7 @@ sub initialize {
my ($self, %conf) = @_; my ($self, %conf) = @_;
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__); $self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
$self->{admins} = PBot::DualIndexHashObject->new(name => 'Admins', filename => $conf{filename}, pbot => $conf{pbot}); $self->{admins} = PBot::DualIndexHashObject->new(name => 'Admins', filename => $conf{filename}, pbot => $conf{pbot});
$self->{commands} = PBot::BotAdminCommands->new(pbot => $conf{pbot}); $self->{commands} = PBot::AdminCommands->new(pbot => $conf{pbot});
$self->load_admins; $self->load_admins;
} }

View File

@ -46,7 +46,7 @@ sub initialize {
$self->init_funcs; $self->init_funcs;
} }
# this is a subroutine so PBot::BotAdminCommands::reload() can reload # this is a subroutine so PBot::AdminCommands::reload() can reload
# the funcs without requiring a bot restart. # the funcs without requiring a bot restart.
sub init_funcs { sub init_funcs {
my ($self) = @_; my ($self) = @_;

View File

@ -37,7 +37,7 @@ use PBot::Interpreter;
use PBot::Commands; use PBot::Commands;
use PBot::ChanOps; use PBot::ChanOps;
use PBot::Factoids; use PBot::Factoids;
use PBot::BotAdmins; use PBot::Admins;
use PBot::IgnoreList; use PBot::IgnoreList;
use PBot::BlackList; use PBot::BlackList;
use PBot::Timer; use PBot::Timer;
@ -188,7 +188,7 @@ sub initialize {
$self->{irchandlers} = PBot::IRCHandlers->new(pbot => $self, %conf); $self->{irchandlers} = PBot::IRCHandlers->new(pbot => $self, %conf);
$self->{select_handler} = PBot::SelectHandler->new(pbot => $self, %conf); $self->{select_handler} = PBot::SelectHandler->new(pbot => $self, %conf);
$self->{stdin_reader} = PBot::StdinReader->new(pbot => $self, %conf); $self->{stdin_reader} = PBot::StdinReader->new(pbot => $self, %conf);
$self->{admins} = PBot::BotAdmins->new(pbot => $self, filename => "$data_dir/admins", %conf); $self->{admins} = PBot::Admins->new(pbot => $self, filename => "$data_dir/admins", %conf);
$self->{bantracker} = PBot::BanTracker->new(pbot => $self, %conf); $self->{bantracker} = PBot::BanTracker->new(pbot => $self, %conf);
$self->{lagchecker} = PBot::LagChecker->new(pbot => $self, %conf); $self->{lagchecker} = PBot::LagChecker->new(pbot => $self, %conf);
$self->{messagehistory} = PBot::MessageHistory->new(pbot => $self, filename => "$data_dir/message_history.sqlite3", %conf); $self->{messagehistory} = PBot::MessageHistory->new(pbot => $self, filename => "$data_dir/message_history.sqlite3", %conf);