Add support for using predefined access token

This commit is contained in:
Alexander Olofsson
2023-03-08 14:41:52 +01:00
parent 1f072d31c8
commit a14f8fe625
4 changed files with 32 additions and 10 deletions

View File

@@ -44,7 +44,8 @@ async def join_room(room_id):
if isinstance(resp, JoinError):
if resp.status_code == "M_UNKNOWN_TOKEN":
LOGGER.warning("Reconnecting")
await CLIENT.login(conf.MATRIX_PW)
if conf.MATRIX_PW:
await CLIENT.login(conf.MATRIX_PW)
else:
return create_json_response(error_map(resp), resp.message)
else:
@@ -67,7 +68,8 @@ async def send_room_message(room_id, content):
if isinstance(resp, RoomSendError):
if resp.status_code == "M_UNKNOWN_TOKEN":
LOGGER.warning("Reconnecting")
await CLIENT.login(conf.MATRIX_PW)
if conf.MATRIX_PW:
await CLIENT.login(conf.MATRIX_PW)
else:
return create_json_response(error_map(resp), resp.message)
else: