From 26f49b8eb7849fd194d9cd4c0486af96d7c50d5c Mon Sep 17 00:00:00 2001 From: Gitea Date: Tue, 24 Mar 2020 17:44:08 +0100 Subject: [PATCH] message: add possibility to mention bot by name with any characters --- src/domain/message.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/domain/message.py b/src/domain/message.py index ac0c686..7545e82 100644 --- a/src/domain/message.py +++ b/src/domain/message.py @@ -58,6 +58,9 @@ class Message(AbstractEntity): """ return random.randint(0, 100) < self.chance + def is_mentioned(self): + return self.text.lower().startswith(config['bot']['mention_name']) or self.text.lower().startswith(config['bot']['mention_name_full']) + def should_answer(self): """ Returns True if bot should answer to this message @@ -66,4 +69,4 @@ class Message(AbstractEntity): return self.has_anchors() \ or self.is_private() \ or self.is_reply_to_bot() \ - or self.is_random_answer() + or self.is_random_answer() or self.is_mentioned()