Compare commits

..

No commits in common. "3a497eae97672d56274030abfd3563affeb92ba1" and "33caf3313670b223e1a00ed8919c3a3c5aff3623" have entirely different histories.

View file

@ -710,15 +710,13 @@ async def getNick(room, message): # Obtenir le DisplayName à partir du mxid.
#except:
# nick = room.user_name(sender)
try:
nick = await bot.client.get_displayname(sender)
#members = await bot.client.api.get_room_members(room.room_id)
#for member in members:
# if member['state_key'] == sender:
# nick = member['content'].get('displayname')
# break
members = await bot.client.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)
async def msg(room,mess,sender,content=False):
@ -931,13 +929,14 @@ async def verifPMRoom(room, message): # Pour obtenir ou créer un salon pour les
bot_nick = await getNick(room, message)
salon = None
room_id = prive.get(sender)
create = False
members = []
try:
await bot.api.send_text_message(room_id, "Information : ")
members = await bot.client.get_room_members(room_id)
print("Les membres du salon prive :")
print(members)
except:
print("Pas d'accès au salon, on le refait")
create = True
if (room_id and not create):
if (room_id and members is not None and len(members) > 0):
await bot.async_client.room_invite(room_id=room_id, user_id=sender)
new_salon = nio.rooms.MatrixRoom(room_id, client_id)
new_salon.name=bot_nick
@ -1256,13 +1255,12 @@ 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.client.get_displayname(message.state_key)
#members = await bot.client.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 = None
members = await bot.client.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
if nick == None:
nick = sender
@ -1338,7 +1336,6 @@ async def addquote(room,message): # enregistrer les citations mode reponses matr
content = getMessage(message)
sender = getUser(message)
nick = None
if len(content) > 42:
# Récupération de l'auteur
auteur = "Un nain connu"
@ -1347,13 +1344,13 @@ async def addquote(room,message): # enregistrer les citations mode reponses matr
auteur = match.group(1)
#nick = room.user_name(auteur)
try:
nick = await bot.client.get_displayname(auteur)
# members = await bot.client.api.get_room_members(room.room_id)
# for member in members:
# if member['state_key'] == auteur:
# nick = member['content'].get('displayname')
# break
members = await bot.client.get_room_members(room.room_id)
for member in members:
if member['state_key'] == auteur:
nick = member['content'].get('displayname')
break
except:
print(members)
nick = sender
# Enlève la commande de la citation