From 53310ede4e85df0a744665a20d0612f313d26f8f Mon Sep 17 00:00:00 2001 From: Klafyvel Date: Sat, 4 Aug 2018 13:14:55 +0200 Subject: [PATCH] Meilleure gestion des usernames --- klafirc/bot.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/klafirc/bot.py b/klafirc/bot.py index 2a5da24..964cbd7 100644 --- a/klafirc/bot.py +++ b/klafirc/bot.py @@ -14,6 +14,7 @@ class Bot: self.server = None self.reactions = {} self.pings = [] + self.tg_user_match = re.compile('^<(?P.+)>') 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,