0

fix empty answer to chat if learn_preply returns undef

This commit is contained in:
eleksir
2022-01-30 15:40:59 +03:00
parent b60bc66b91
commit c6a1b70110

View File

@@ -71,12 +71,11 @@ sub RunIRCBot {
} }
} }
$answer = eval { $answer = $hailo->{$chatid}->learn_reply ($phrase);
sprintf '%s, %s', $nick, lcfirst ($hailo->{$chatid}->learn_reply ($phrase));
};
unless (defined $answer) { if (defined $answer) {
$log->warn ($EVAL_ERROR); $answer = sprintf '%s, %s', $nick, lcfirst ($answer);
} else {
$answer = sprintf '%s, %s', $nick, RandomCommonPhrase (); $answer = sprintf '%s, %s', $nick, RandomCommonPhrase ();
} }
} elsif (substr ($text, -2) eq '++' || substr ($text, -2) eq '--') { } elsif (substr ($text, -2) eq '++' || substr ($text, -2) eq '--') {