matrix-bot/matrix_bot/client.py

19 lines
670 B
Python
Raw Normal View History

2020-08-06 17:16:43 +02:00
import aiohttp
async def send_message(room: str, message: str) -> None:
conn = aiohttp.UnixConnector(path='/tmp/test.sock')
try:
async with aiohttp.request('POST',
'http://localhost/',
json={
'type': 'message.text',
'room_id': room,
'message': message
},
connector=conn) as resp:
assert resp.status == 200
print(await resp.text())
finally:
await conn.close()