1

Implement fuzzy matching in bred answer checking to avoid repeating input phrase.

This commit is contained in:
eleksir
2020-12-20 14:18:04 +03:00
parent 07275c5b43
commit 0cfecd72b3
3 changed files with 20 additions and 8 deletions

View File

@@ -12,7 +12,7 @@ use File::Path qw(mkpath);
use Hailo;
use Mojo::Base 'Teapot::Bot::Brain';
use conf qw(loadConf);
use botlib qw(weather trim randomCommonPhrase command highlight botsleep);
use botlib qw(weather trim randomCommonPhrase command highlight botsleep fmatch);
use karma qw(karmaSet);
use fortune qw(fortune fortune_toggle_list);
@@ -287,12 +287,7 @@ sub __on_msg {
$phrase = lc ($phrase);
if (lc ($reply) eq $phrase) {
$reply = randomCommonPhrase ();
} elsif (lc ($reply) eq substr ($phrase, 0, -1)) {
# in case of trailing dot
$reply = randomCommonPhrase ();
} elsif (substr (lc ($reply), 0, -1) eq $phrase) {
if (fmatch (lc ($reply), $phrase)) {
$reply = randomCommonPhrase ();
}