Factoids: restore missing log_factoid() when creating factoids; minor clean-ups

This commit is contained in:
Pragmatic Software 2021-07-05 11:41:25 -07:00
parent dbfbff08de
commit f0fa806fd6
3 changed files with 10 additions and 7 deletions

View File

@ -433,7 +433,7 @@ sub get_each {
};
if ($@) {
$self->{pbot}->{logger}->log("Error getting data: $@\n");
$self->{pbot}->{logger}->log("Error getting data: $@");
return undef;
}
@ -448,7 +448,7 @@ sub get_next {
};
if ($@) {
$self->{pbot}->{logger}->log("Error getting next: $@\n");
$self->{pbot}->{logger}->log("Error getting next: $@");
return undef;
}

View File

@ -663,6 +663,7 @@ sub cmd_factadd {
$self->{pbot}->{factoids}->add_factoid('text', $from_chan, $context->{hostmask}, $keyword, $text);
$self->{pbot}->{logger}->log("$context->{hostmask} added [$from_chan] $keyword_text => $text\n");
$self->log_factoid($channel, $trigger, $context->{hostmask}, "created");
return "/say $keyword_text added to " . ($from_chan eq '.*' ? 'global channel' : $from_chan) . ".";
}
@ -961,8 +962,8 @@ sub cmd_factfind {
my $unquoted_args = $arguments;
$unquoted_args =~ s/(?:\\(?!\\))//g;
$unquoted_args =~ s/(?:\\\\)/\\/g;
if (not defined $argtype) { $argtype = "with text containing '$unquoted_args'"; }
else { $argtype .= " and with text containing '$unquoted_args'"; }
if (not defined $argtype) { $argtype = "containing '$unquoted_args'"; }
else { $argtype .= " and containing '$unquoted_args'"; }
}
if (not defined $argtype) { return $usage; }
@ -1021,14 +1022,14 @@ sub cmd_factfind {
if ($i == 1) {
chop $text;
return
"Found one factoid submitted for "
. ($last_chan eq '.*' ? 'global channel' : $factoids->get_data($last_chan, '_name')) . ' '
"Found one factoid in "
. ($last_chan eq '.*' ? 'global' : $factoids->get_data($last_chan, '_name')) . ' '
. $argtype
. ": $last_trigger is "
. $factoids->get_data($last_chan, $last_trigger, 'action');
} else {
return "Found $i factoids " . $argtype . ": $text" unless $i == 0;
my $chans = (defined $channel ? ($channel eq '.*' ? 'global channel' : $channel) : 'any channels');
my $chans = (defined $channel ? ($channel eq '.*' ? 'global' : $channel) : 'any channels');
return "No factoids " . $argtype . " submitted for $chans.";
}
}

View File

@ -144,6 +144,8 @@ sub export_factoids {
else { $filename = $self->{pbot}->{registry}->get_value('general', 'data_dir') . '/factoids.html'; }
return if not defined $filename;
return if not defined $self->{factoids}->{dbh};
$self->{pbot}->{logger}->log("Exporting factoids to $filename\n");
open FILE, "> $filename" or return "Could not open export path.";