Meilleure gestion des usernames
This commit is contained in:
parent
7262f26034
commit
53310ede4e
1 changed files with 4 additions and 0 deletions
|
@ -14,6 +14,7 @@ class Bot:
|
||||||
self.server = None
|
self.server = None
|
||||||
self.reactions = {}
|
self.reactions = {}
|
||||||
self.pings = []
|
self.pings = []
|
||||||
|
self.tg_user_match = re.compile('^<(?P<username>.+)>')
|
||||||
self.ping_match = re.compile('^(<.+> )?\@?{name}'.format(name=nickname))
|
self.ping_match = re.compile('^(<.+> )?\@?{name}'.format(name=nickname))
|
||||||
|
|
||||||
def add_reaction(self, match, reaction):
|
def add_reaction(self, match, reaction):
|
||||||
|
@ -47,6 +48,9 @@ class Bot:
|
||||||
Every matched reactions.
|
Every matched reactions.
|
||||||
"""
|
"""
|
||||||
username = user.split('!')[0]
|
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 = {
|
context = {
|
||||||
'server': self.server,
|
'server': self.server,
|
||||||
|
|
Loading…
Reference in a new issue