fix(bot): separate user_id from client creation

Removed user_id from the AsyncClient constructor and set it separately on the client object. This change ensures that the user_id is consistently assigned regardless of the homeserver type, improving maintainability and clarity of client configuration.
This commit is contained in:
Kumi 2024-08-09 11:11:56 +02:00
parent e0f3408b5c
commit eadc4d7791
Signed by: kumi
GPG key ID: ECBCC9082395383F

6
bot.py
View file

@ -29,13 +29,15 @@ class RoombaBot:
self.access_token = access_token self.access_token = access_token
if pantalaimon_homeserver and pantalaimon_token: if pantalaimon_homeserver and pantalaimon_token:
self.client = nio.AsyncClient(pantalaimon_homeserver, user_id) self.client = nio.AsyncClient(pantalaimon_homeserver)
self.client.access_token = pantalaimon_token self.client.access_token = pantalaimon_token
else: else:
self.client = nio.AsyncClient(homeserver, user_id) self.client = nio.AsyncClient(homeserver)
self.client.access_token = access_token self.client.access_token = access_token
self.client.user_id = user_id
self.moderation_room_id = moderation_room_id self.moderation_room_id = moderation_room_id
self.logger = logging.getLogger(__name__) self.logger = logging.getLogger(__name__)
self.logger.setLevel(logging.DEBUG) self.logger.setLevel(logging.DEBUG)