bot.client --> bot.api

This commit is contained in:
nemesis 2025-11-11 22:20:41 +01:00
parent fdd8a381c8
commit e0b38beb7e

View file

@ -76,8 +76,12 @@ else:
print("Probleme de lecture de configuration asmodee.ini")
# Create an instance of the MatrixBotAPI
config = botlib.Config()
config.encryption_enabled = True
config.emoji_verify = True
config.ignore_unverified_devices = False
creds = botlib.Creds(SERVER, USERNAME, PASSWORD)
bot = botlib.Bot(creds)
bot = botlib.Bot(creds, config)
# Chargement des données persistantes
def horloge_read():
@ -710,8 +714,8 @@ 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)
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')
@ -750,7 +754,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.client.user_id):
if (sender in admins or sender in lmod or sender == bot.api.whoami()):
args = texte.split()
args.pop(0)
if (len(args) > 1 and args[0] == "add"):
@ -785,7 +789,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.client.user_id):
if (sender in admins or sender in lmod or sender == bot.api.whoami()):
global modules
args = texte.split()
args.pop(0)
@ -1262,8 +1266,8 @@ async def bienvenue(room,message): # Affichage d'un message d'accueil aux nouvea
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)
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')
@ -1352,8 +1356,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.client.get_displayname(auteur)
# members = await bot.client.api.get_room_members(room.room_id)
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')