mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 13:59:47 +01:00
Refresher: very minor clean-up
This commit is contained in:
parent
0881f54c6d
commit
186f0d3d65
@ -2,7 +2,8 @@
|
|||||||
# Author: pragma_
|
# Author: pragma_
|
||||||
#
|
#
|
||||||
# Purpose: Refreshes/reloads module subroutines. Does not refresh/reload
|
# Purpose: Refreshes/reloads module subroutines. Does not refresh/reload
|
||||||
# module member data, only subroutines.
|
# module member data, only subroutines. TODO: reinitialize modules in order
|
||||||
|
# to refresh member data too.
|
||||||
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# 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
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
@ -19,12 +20,8 @@ use Module::Refresh;
|
|||||||
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 " . __FILE__ . " 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;
|
||||||
@ -32,13 +29,9 @@ sub new {
|
|||||||
|
|
||||||
sub initialize {
|
sub initialize {
|
||||||
my ($self, %conf) = @_;
|
my ($self, %conf) = @_;
|
||||||
|
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||||
my $pbot = delete $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
|
||||||
$self->{pbot} = $pbot;
|
|
||||||
|
|
||||||
$self->{refresher} = Module::Refresh->new;
|
$self->{refresher} = Module::Refresh->new;
|
||||||
|
$self->{pbot}->{commands}->register(sub { return $self->refresh(@_) }, "refresh", 1);
|
||||||
$pbot->{commands}->register(sub { return $self->refresh(@_) }, "refresh", 90);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub refresh {
|
sub refresh {
|
||||||
@ -61,7 +54,6 @@ sub refresh {
|
|||||||
$self->{pbot}->{logger}->log("Error refreshing: $@\n");
|
$self->{pbot}->{logger}->log("Error refreshing: $@\n");
|
||||||
return $@;
|
return $@;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user