message: add possibility to mention bot by name with any characters

This commit is contained in:
Gitea 2020-03-24 17:44:08 +01:00
parent 15566baf1a
commit 26f49b8eb7
1 changed files with 4 additions and 1 deletions

View File

@ -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()