add pong callback

master
histausse 2 years ago
parent 8165f2b1c0
commit 0de8d9f036
Signed by: histausse
GPG Key ID: 67486F107F62E9E9

@ -7,11 +7,25 @@ from typing import (
Any,
NoReturn
)
import nio
from matrix_bot.client import Client
from matrix_bot.invite_policy import WhiteList
from matrix_bot.utils import ignore_client_message
from .config import Config
from .format import Message
@ignore_client_message
async def __pong(
client: Client,
room: nio.rooms.MatrixRoom,
message: nio.events.room_events.RoomMessageText
):
"""
If the bot is pinged, send "Pong"
"""
if (client.user_name + ':') in message.body:
await client.send_message(room.room_id, "Pong")
async def __send_messsages(
message_queue: asyncio.Queue[Message],
bot: Client,
@ -45,6 +59,7 @@ async def send_messages(
)
invite_policy = await WhiteList(bot, config.alert_rooms)
bot.set_invite_policy(invite_policy)
bot.add_message_callback(__pong)
await asyncio.gather(
bot.run(),
__send_messsages(

Loading…
Cancel
Save