From 532fc9c8fcbb07c743bef1693733a748f4df55ec Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 21 Dec 2019 19:01:32 -0800 Subject: [PATCH] Registry: add dont_save option to set() --- PBot/Registry.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PBot/Registry.pm b/PBot/Registry.pm index 0467726e..b37745b4 100644 --- a/PBot/Registry.pm +++ b/PBot/Registry.pm @@ -35,8 +35,8 @@ sub new { sub initialize { my ($self, %conf) = @_; - $self->{pbot} = delete $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__); - my $filename = delete $conf{filename}; + $self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__); + my $filename = $conf{filename} // Carp::croak("Missing filename reference in " . __FILE__); $self->{registry} = PBot::DualIndexHashObject->new(name => 'Registry', filename => $filename, pbot => $self->{pbot}); $self->{triggers} = {}; @@ -106,7 +106,7 @@ sub set_default { } sub set { - my ($self, $section, $item, $key, $value, $is_default) = @_; + my ($self, $section, $item, $key, $value, $is_default, $dont_save) = @_; $section = lc $section; $item = lc $item; @@ -127,7 +127,7 @@ sub set { $self->process_trigger($section, $item, $value); } - $self->save if $result =~ m/set to/ && not $is_default; + $self->save if !$dont_save && $result =~ m/set to/ && not $is_default; return $result; }