matrixbot: Send a greeting when first connected

This commit is contained in:
Tristan Daniël Maat 2023-05-20 02:52:43 +01:00
parent 5ba466b7aa
commit 0b1683933f
Signed by: tlater
GPG key ID: 49670FD774E43268

View file

@ -41,6 +41,7 @@ class MatrixBot:
logger.debug(f"left room {room_id} since all other users left") logger.debug(f"left room {room_id} since all other users left")
logger.info("initial sync done, ready for work") logger.info("initial sync done, ready for work")
await self._send_greeting()
async def _on_invite(self, room, event): async def _on_invite(self, room, event):
logger.info(f"invited by {event.sender} to {room.room_id}") logger.info(f"invited by {event.sender} to {room.room_id}")
@ -93,6 +94,20 @@ class MatrixBot:
}, },
) )
async def _send_greeting(self):
"""Send a greeting to make sure the bot is working."""
assert self.client
for room_id in self.client.rooms:
await self.client.room_send(
room_id=room_id,
message_type="m.room.message",
content={
"msgtype": "m.text",
"body": "Whaaaaaaa, good monning. I'll check slots for you.",
},
)
async def run(self): async def run(self):
"""Start the bot.""" """Start the bot."""
logger.info(f"Connecting to {self.homeserver}") logger.info(f"Connecting to {self.homeserver}")