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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user