diff --git a/PBot/DualIndexHashObject.pm b/PBot/DualIndexHashObject.pm index 67762990..fbd3f3d4 100644 --- a/PBot/DualIndexHashObject.pm +++ b/PBot/DualIndexHashObject.pm @@ -154,10 +154,10 @@ sub find_index { return undef if not defined $primary_index_key; - return $primary_index_key if not $secondary_index_key; - return undef if not exists $self->hash->{$primary_index_key}; + return $primary_index_key if not defined $secondary_index_key; + foreach my $index (keys %{ $self->hash->{$primary_index_key} }) { return $index if $secondary_index_key eq lc $index; } diff --git a/PBot/FactoidCommands.pm b/PBot/FactoidCommands.pm index 4c617260..68e053b3 100644 --- a/PBot/FactoidCommands.pm +++ b/PBot/FactoidCommands.pm @@ -161,6 +161,8 @@ sub factset { } } + my $oldvalue; + if(defined $owner_channel) { my $factoid = $self->{pbot}->{factoids}->{factoids}->hash->{$owner_channel}->{$owner_trigger}; @@ -169,9 +171,9 @@ sub factset { if(lc $nick ne lc $owner and $level == 0) { return "You are not the owner of $trigger."; } - } - my $oldvalue = $self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$trigger}->{$key}; + $oldvalue = $self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$trigger}->{$key}; + } my $result = $self->{pbot}->{factoids}->{factoids}->set($channel, $trigger, $key, $value); @@ -226,6 +228,8 @@ sub factunset { } } + my $oldvalue; + if(defined $owner_channel) { my $factoid = $self->{pbot}->{factoids}->{factoids}->hash->{$owner_channel}->{$owner_trigger}; @@ -234,9 +238,9 @@ sub factunset { if(lc $nick ne lc $owner and $level == 0) { return "You are not the owner of $trigger."; } + $oldvalue = $self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$trigger}->{$key}; } - my $oldvalue = $self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$trigger}->{$key}; my $result = $self->{pbot}->{factoids}->{factoids}->unset($channel, $trigger, $key); if ($result =~ m/unset/) {