From cf054631e85f405fe8a25a58caaedaa95aadeed5 Mon Sep 17 00:00:00 2001 From: Jochen Kupperschmidt Date: Sun, 27 Dec 2020 14:07:04 +0100 Subject: [PATCH] Extract room ID into variable --- matrix_webhook.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/matrix_webhook.py b/matrix_webhook.py index 5ffb69f..9e5fb44 100755 --- a/matrix_webhook.py +++ b/matrix_webhook.py @@ -43,6 +43,7 @@ async def handler(request): status, ret = HTTPStatus.UNAUTHORIZED, 'I need the good "key"' if data['key'] == API_KEY: status, ret = HTTPStatus.OK, 'OK' + room_id = str(request.rel_url)[1:] content = { "msgtype": "m.text", "body": data['text'], @@ -50,12 +51,12 @@ async def handler(request): "formatted_body": markdown(data['text'], extensions=['extra']), } try: - await CLIENT.room_send(room_id=str(request.rel_url)[1:], + await CLIENT.room_send(room_id=room_id, message_type="m.room.message", content=content) except LocalProtocolError: # Connection lost, try another login await CLIENT.login(MATRIX_PW) - await CLIENT.room_send(room_id=str(request.rel_url)[1:], + await CLIENT.room_send(room_id=room_id, message_type="m.room.message", content=content)