Fix minor bug creating empty factoid in factset without key argument

This commit is contained in:
Pragmatic Software 2015-12-13 22:08:17 -08:00
parent 03389d4d08
commit eb5d90ec48
2 changed files with 9 additions and 5 deletions

View File

@ -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;
}

View File

@ -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/) {