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)
|
sender = getUser(message)
|
||||||
nick = None
|
nick = None
|
||||||
try:
|
try:
|
||||||
nick = room.user_name(sender).split(' ')[0]
|
response = await bot.api.async_client.get_displayname(sender)
|
||||||
|
nick = response.displayname
|
||||||
except:
|
except:
|
||||||
nick = sender
|
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
|
nick = nick if nick is not None else sender
|
||||||
return(nick)
|
return(nick)
|
||||||
|
|
||||||
|
|
@ -755,7 +747,7 @@ async def modo(room,message): # Definition d'un moderateur
|
||||||
lmod = modos.get(room.room_id)
|
lmod = modos.get(room.room_id)
|
||||||
except:
|
except:
|
||||||
lmod = []
|
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 = texte.split()
|
||||||
args.pop(0)
|
args.pop(0)
|
||||||
if (len(args) > 1 and args[0] == "add"):
|
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)
|
lmod = modos.get(room.room_id)
|
||||||
except:
|
except:
|
||||||
lmod = []
|
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
|
global modules
|
||||||
args = texte.split()
|
args = texte.split()
|
||||||
args.pop(0)
|
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
|
modules[room.room_id, 'welcome'] = False
|
||||||
if (modules[room.room_id, 'welcome']):
|
if (modules[room.room_id, 'welcome']):
|
||||||
sender = getUser(message)
|
sender = getUser(message)
|
||||||
#nick = None
|
nick = None
|
||||||
nick = await bot.api.get_displayname(message.state_key)
|
response = await bot.api.async_client.get_displayname(sender)
|
||||||
#members = await bot.api.get_room_members(room.room_id)
|
nick = response.displayname
|
||||||
#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
|
|
||||||
if nick == None:
|
if nick == None:
|
||||||
nick = sender
|
nick = sender
|
||||||
membership = message.membership
|
membership = message.membership
|
||||||
|
|
@ -1357,12 +1344,8 @@ async def addquote(room,message): # enregistrer les citations mode reponses matr
|
||||||
auteur = match.group(1)
|
auteur = match.group(1)
|
||||||
#nick = room.user_name(auteur)
|
#nick = room.user_name(auteur)
|
||||||
try:
|
try:
|
||||||
nick = await bot.api.get_displayname(auteur)
|
response = await bot.api.async_client.get_displayname(auteur)
|
||||||
# members = await bot.api.get_room_members(room.room_id)
|
nick = response.displayname
|
||||||
# for member in members:
|
|
||||||
# if member['state_key'] == auteur:
|
|
||||||
# nick = member['content'].get('displayname')
|
|
||||||
# break
|
|
||||||
except:
|
except:
|
||||||
nick = sender
|
nick = sender
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue