From 186f0d3d659d147292a0ce89c889df0ef86b0d97 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Mon, 3 Feb 2020 09:48:19 -0800 Subject: [PATCH] Refresher: very minor clean-up --- PBot/Refresher.pm | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/PBot/Refresher.pm b/PBot/Refresher.pm index ca4f9a46..070b9826 100644 --- a/PBot/Refresher.pm +++ b/PBot/Refresher.pm @@ -2,7 +2,8 @@ # Author: pragma_ # # 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 # License, v. 2.0. If a copy of the MPL was not distributed with this @@ -19,12 +20,8 @@ use Module::Refresh; use Carp (); sub new { - if (ref($_[1]) eq 'HASH') { - Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference"); - } - + Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref($_[1]) eq 'HASH'; my ($class, %conf) = @_; - my $self = bless {}, $class; $self->initialize(%conf); return $self; @@ -32,13 +29,9 @@ sub new { sub initialize { my ($self, %conf) = @_; - - my $pbot = delete $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__); - $self->{pbot} = $pbot; - + $self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__); $self->{refresher} = Module::Refresh->new; - - $pbot->{commands}->register(sub { return $self->refresh(@_) }, "refresh", 90); + $self->{pbot}->{commands}->register(sub { return $self->refresh(@_) }, "refresh", 1); } sub refresh { @@ -61,7 +54,6 @@ sub refresh { $self->{pbot}->{logger}->log("Error refreshing: $@\n"); return $@; } - return $result; }