Meilleure gestion des usernames

This commit is contained in:
Klafyvel 2018-08-04 13:14:55 +02:00
parent 7262f26034
commit 53310ede4e

View file

@ -14,6 +14,7 @@ class Bot:
self.server = None
self.reactions = {}
self.pings = []
self.tg_user_match = re.compile('^<(?P<username>.+)>')
self.ping_match = re.compile('^(<.+> )?\@?{name}'.format(name=nickname))
def add_reaction(self, match, reaction):
@ -47,6 +48,9 @@ class Bot:
Every matched reactions.
"""
username = user.split('!')[0]
tg_user_match = self.tg_user_match.match(message)
if 'bot' in username.lower() and tg_user_match:
username = '@' + tg_user_match.groupdict()
context = {
'server': self.server,