generated from Nemesis/Exemple
async_client
This commit is contained in:
parent
179561c3df
commit
549f91b92c
1 changed files with 9 additions and 26 deletions
35
asmodee.py
35
asmodee.py
|
|
@ -711,18 +711,10 @@ async def getNick(room, message): # Obtenir le DisplayName à partir du mxid.
|
|||
sender = getUser(message)
|
||||
nick = None
|
||||
try:
|
||||
nick = room.user_name(sender).split(' ')[0]
|
||||
response = await bot.api.async_client.get_displayname(sender)
|
||||
nick = response.displayname
|
||||
except:
|
||||
nick = sender
|
||||
#try:
|
||||
#nick = await bot.api.get_displayname(sender)
|
||||
#members = await bot.api.get_room_members(room.room_id)
|
||||
#for member in members:
|
||||
# if member['state_key'] == sender:
|
||||
# nick = member['content'].get('displayname')
|
||||
# break
|
||||
#except:
|
||||
#nick = sender
|
||||
nick = nick if nick is not None else sender
|
||||
return(nick)
|
||||
|
||||
|
|
@ -755,7 +747,7 @@ async def modo(room,message): # Definition d'un moderateur
|
|||
lmod = modos.get(room.room_id)
|
||||
except:
|
||||
lmod = []
|
||||
if (sender in admins or sender in lmod or sender == bot.api.whoami()):
|
||||
if (sender in admins or sender in lmod or sender == bot.api.async_client.whoami()):
|
||||
args = texte.split()
|
||||
args.pop(0)
|
||||
if (len(args) > 1 and args[0] == "add"):
|
||||
|
|
@ -790,7 +782,7 @@ async def module(room,message): # Definition des modules d'un salon
|
|||
lmod = modos.get(room.room_id)
|
||||
except:
|
||||
lmod = []
|
||||
if (sender in admins or sender in lmod or sender == bot.api.whoami()):
|
||||
if (sender in admins or sender in lmod or sender == bot.api.async_client.whoami()):
|
||||
global modules
|
||||
args = texte.split()
|
||||
args.pop(0)
|
||||
|
|
@ -1266,14 +1258,9 @@ async def bienvenue(room,message): # Affichage d'un message d'accueil aux nouvea
|
|||
modules[room.room_id, 'welcome'] = False
|
||||
if (modules[room.room_id, 'welcome']):
|
||||
sender = getUser(message)
|
||||
#nick = None
|
||||
nick = await bot.api.get_displayname(message.state_key)
|
||||
#members = await bot.api.get_room_members(room.room_id)
|
||||
#for member in members:
|
||||
# if member['state_key'] == message.state_key:
|
||||
# nick = member['content'].get('displayname')
|
||||
# break
|
||||
#nick = room.user_name(message.state_key) if room.user_name(message.state_key) else message.state_key
|
||||
nick = None
|
||||
response = await bot.api.async_client.get_displayname(sender)
|
||||
nick = response.displayname
|
||||
if nick == None:
|
||||
nick = sender
|
||||
membership = message.membership
|
||||
|
|
@ -1357,12 +1344,8 @@ async def addquote(room,message): # enregistrer les citations mode reponses matr
|
|||
auteur = match.group(1)
|
||||
#nick = room.user_name(auteur)
|
||||
try:
|
||||
nick = await bot.api.get_displayname(auteur)
|
||||
# members = await bot.api.get_room_members(room.room_id)
|
||||
# for member in members:
|
||||
# if member['state_key'] == auteur:
|
||||
# nick = member['content'].get('displayname')
|
||||
# break
|
||||
response = await bot.api.async_client.get_displayname(auteur)
|
||||
nick = response.displayname
|
||||
except:
|
||||
nick = sender
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue