Extract room ID into variable
This commit is contained in:
parent
6c138a65b4
commit
cf054631e8
1 changed files with 3 additions and 2 deletions
|
@ -43,6 +43,7 @@ async def handler(request):
|
||||||
status, ret = HTTPStatus.UNAUTHORIZED, 'I need the good "key"'
|
status, ret = HTTPStatus.UNAUTHORIZED, 'I need the good "key"'
|
||||||
if data['key'] == API_KEY:
|
if data['key'] == API_KEY:
|
||||||
status, ret = HTTPStatus.OK, 'OK'
|
status, ret = HTTPStatus.OK, 'OK'
|
||||||
|
room_id = str(request.rel_url)[1:]
|
||||||
content = {
|
content = {
|
||||||
"msgtype": "m.text",
|
"msgtype": "m.text",
|
||||||
"body": data['text'],
|
"body": data['text'],
|
||||||
|
@ -50,12 +51,12 @@ async def handler(request):
|
||||||
"formatted_body": markdown(data['text'], extensions=['extra']),
|
"formatted_body": markdown(data['text'], extensions=['extra']),
|
||||||
}
|
}
|
||||||
try:
|
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",
|
message_type="m.room.message",
|
||||||
content=content)
|
content=content)
|
||||||
except LocalProtocolError: # Connection lost, try another login
|
except LocalProtocolError: # Connection lost, try another login
|
||||||
await CLIENT.login(MATRIX_PW)
|
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",
|
message_type="m.room.message",
|
||||||
content=content)
|
content=content)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue