Add trim() and random pre-generated phrase answer

+ Add php-inspired trim() function
+ Add randomCommonPhrase() in order not to repeat given sentense if unable to produce relevant phrase from vocabulary generator
This commit is contained in:
eleksir
2020-09-09 14:54:38 +03:00
parent 20bbfab333
commit c3d2d76ad4
2 changed files with 36 additions and 1 deletions

View File

@@ -137,6 +137,15 @@ sub __on_msg {
}
if (defined($reply) && $reply ne '') {
if (lc($reply) eq lc(trim($text))) {
$reply = randomCommonPhrase();
}
# in case of trailing dot
if (lc($reply) eq substr(lc(trim($text)), 0, -1)) {
$reply = randomCommonPhrase();
}
logger ("reply with: $reply");
$msg->reply($reply);
} else {