matrixbot: Send a greeting when first connected

main
Tristan Daniël Maat 2023-05-20 02:52:43 +01:00
parent 5ba466b7aa
commit 0b1683933f
Signed by: tlater
GPG Key ID: 49670FD774E43268
1 changed files with 15 additions and 0 deletions

View File

@ -41,6 +41,7 @@ class MatrixBot:
logger.debug(f"left room {room_id} since all other users left")
logger.info("initial sync done, ready for work")
await self._send_greeting()
async def _on_invite(self, room, event):
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):
"""Start the bot."""
logger.info(f"Connecting to {self.homeserver}")