generated from Nemesis/Exemple
Compare commits
2 commits
33caf33136
...
3a497eae97
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a497eae97 | |||
| a5dc420dd0 |
1 changed files with 25 additions and 22 deletions
47
asmodee.py
47
asmodee.py
|
|
@ -710,13 +710,15 @@ async def getNick(room, message): # Obtenir le DisplayName à partir du mxid.
|
||||||
#except:
|
#except:
|
||||||
# nick = room.user_name(sender)
|
# nick = room.user_name(sender)
|
||||||
try:
|
try:
|
||||||
members = await bot.client.get_room_members(room.room_id)
|
nick = await bot.client.get_displayname(sender)
|
||||||
for member in members:
|
#members = await bot.client.api.get_room_members(room.room_id)
|
||||||
if member['state_key'] == sender:
|
#for member in members:
|
||||||
nick = member['content'].get('displayname')
|
# if member['state_key'] == sender:
|
||||||
break
|
# nick = member['content'].get('displayname')
|
||||||
|
# break
|
||||||
except:
|
except:
|
||||||
nick = sender
|
nick = sender
|
||||||
|
nick = nick if nick is not None else sender
|
||||||
return(nick)
|
return(nick)
|
||||||
|
|
||||||
async def msg(room,mess,sender,content=False):
|
async def msg(room,mess,sender,content=False):
|
||||||
|
|
@ -929,14 +931,13 @@ async def verifPMRoom(room, message): # Pour obtenir ou créer un salon pour les
|
||||||
bot_nick = await getNick(room, message)
|
bot_nick = await getNick(room, message)
|
||||||
salon = None
|
salon = None
|
||||||
room_id = prive.get(sender)
|
room_id = prive.get(sender)
|
||||||
members = []
|
create = False
|
||||||
try:
|
try:
|
||||||
members = await bot.client.get_room_members(room_id)
|
await bot.api.send_text_message(room_id, "Information : ")
|
||||||
print("Les membres du salon prive :")
|
|
||||||
print(members)
|
|
||||||
except:
|
except:
|
||||||
print("Pas d'accès au salon, on le refait")
|
print("Pas d'accès au salon, on le refait")
|
||||||
if (room_id and members is not None and len(members) > 0):
|
create = True
|
||||||
|
if (room_id and not create):
|
||||||
await bot.async_client.room_invite(room_id=room_id, user_id=sender)
|
await bot.async_client.room_invite(room_id=room_id, user_id=sender)
|
||||||
new_salon = nio.rooms.MatrixRoom(room_id, client_id)
|
new_salon = nio.rooms.MatrixRoom(room_id, client_id)
|
||||||
new_salon.name=bot_nick
|
new_salon.name=bot_nick
|
||||||
|
|
@ -1255,12 +1256,13 @@ 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
|
||||||
members = await bot.client.get_room_members(room.room_id)
|
nick = await bot.client.get_displayname(message.state_key)
|
||||||
for member in members:
|
#members = await bot.client.api.get_room_members(room.room_id)
|
||||||
if member['state_key'] == message.state_key:
|
#for member in members:
|
||||||
nick = member['content'].get('displayname')
|
# if member['state_key'] == message.state_key:
|
||||||
break
|
# 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 = 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
|
||||||
|
|
@ -1336,6 +1338,7 @@ async def addquote(room,message): # enregistrer les citations mode reponses matr
|
||||||
|
|
||||||
content = getMessage(message)
|
content = getMessage(message)
|
||||||
sender = getUser(message)
|
sender = getUser(message)
|
||||||
|
nick = None
|
||||||
if len(content) > 42:
|
if len(content) > 42:
|
||||||
# Récupération de l'auteur
|
# Récupération de l'auteur
|
||||||
auteur = "Un nain connu"
|
auteur = "Un nain connu"
|
||||||
|
|
@ -1344,13 +1347,13 @@ 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:
|
||||||
members = await bot.client.get_room_members(room.room_id)
|
nick = await bot.client.get_displayname(auteur)
|
||||||
for member in members:
|
# members = await bot.client.api.get_room_members(room.room_id)
|
||||||
if member['state_key'] == auteur:
|
# for member in members:
|
||||||
nick = member['content'].get('displayname')
|
# if member['state_key'] == auteur:
|
||||||
break
|
# nick = member['content'].get('displayname')
|
||||||
|
# break
|
||||||
except:
|
except:
|
||||||
print(members)
|
|
||||||
nick = sender
|
nick = sender
|
||||||
|
|
||||||
# Enlève la commande de la citation
|
# Enlève la commande de la citation
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue