From 1800b0c0fc73d1229c1af7b252ac214bacf1642b Mon Sep 17 00:00:00 2001 From: gammafn Date: Mon, 17 May 2021 16:20:41 -0500 Subject: [PATCH] Simplify !bot ping by having bot return await room_send() --- bot.py | 4 ++-- modules/bot.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bot.py b/bot.py index 20a6891..1f0a0e7 100755 --- a/bot.py +++ b/bot.py @@ -159,7 +159,7 @@ class Bot: :param body: Textual content of the message :param msgtype: The message type for the room https://matrix.org/docs/spec/client_server/latest#m-room-message-msgtypes :param bot_ignore: Flag to mark the message to be ignored by the bot - :return: + :return: the NIO Response from room_send() """ msg = { @@ -169,7 +169,7 @@ class Bot: if bot_ignore: msg["org.vranki.hemppa.ignore"] = "true" - await self.client.room_send(room.room_id, 'm.room.message', msg) + return await self.client.room_send(room.room_id, 'm.room.message', msg) async def send_html(self, room, html, plaintext, msgtype="m.notice", bot_ignore=False): """ diff --git a/modules/bot.py b/modules/bot.py index c805702..0c48354 100644 --- a/modules/bot.py +++ b/modules/bot.py @@ -83,8 +83,7 @@ class MatrixModule(BotModule): # initial pong serv_before = event.server_timestamp local_before = time.time() - pong = await bot.client.room_send(room.room_id, 'm.room.message', - {'body': f'Pong!', 'msgtype': 'm.notice'}) + pong = await bot.client.send_text(room, 'Pong!') local_delta = int((time.time() - local_before) * 1000) # ask the server what the timestamp was on our pong