Simplify !bot ping by having bot return await room_send()
This commit is contained in:
parent
a9681e04d7
commit
1800b0c0fc
4
bot.py
4
bot.py
|
@ -159,7 +159,7 @@ class Bot:
|
||||||
:param body: Textual content of the message
|
: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 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
|
:param bot_ignore: Flag to mark the message to be ignored by the bot
|
||||||
:return:
|
:return: the NIO Response from room_send()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
msg = {
|
msg = {
|
||||||
|
@ -169,7 +169,7 @@ class Bot:
|
||||||
if bot_ignore:
|
if bot_ignore:
|
||||||
msg["org.vranki.hemppa.ignore"] = "true"
|
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):
|
async def send_html(self, room, html, plaintext, msgtype="m.notice", bot_ignore=False):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -83,8 +83,7 @@ class MatrixModule(BotModule):
|
||||||
# initial pong
|
# initial pong
|
||||||
serv_before = event.server_timestamp
|
serv_before = event.server_timestamp
|
||||||
local_before = time.time()
|
local_before = time.time()
|
||||||
pong = await bot.client.room_send(room.room_id, 'm.room.message',
|
pong = await bot.client.send_text(room, 'Pong!')
|
||||||
{'body': f'Pong!', 'msgtype': 'm.notice'})
|
|
||||||
local_delta = int((time.time() - local_before) * 1000)
|
local_delta = int((time.time() - local_before) * 1000)
|
||||||
|
|
||||||
# ask the server what the timestamp was on our pong
|
# ask the server what the timestamp was on our pong
|
||||||
|
|
Loading…
Reference in New Issue