Simplify !bot ping by having bot return await room_send()

This commit is contained in:
gammafn 2021-05-17 16:20:41 -05:00
parent a9681e04d7
commit 1800b0c0fc
2 changed files with 3 additions and 4 deletions

4
bot.py
View File

@ -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):
"""

View File

@ -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