From 3e15ae426c24803345b22235881b9b67a4763fcc Mon Sep 17 00:00:00 2001 From: nikita Date: Sat, 12 Sep 2026 18:06:55 +0300 Subject: [PATCH] Added `MatrixBot.run()` for dev simplification --- src/mab/bot/bot.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/mab/bot/bot.py b/src/mab/bot/bot.py index 81a3611..b454e2a 100644 --- a/src/mab/bot/bot.py +++ b/src/mab/bot/bot.py @@ -1,3 +1,4 @@ +import asyncio import logging from typing import Callable, Coroutine, Any @@ -97,6 +98,20 @@ class MatrixBot: """ await self._client_manager.stop() + async def run(self) -> None: + """ + Start bot operation in foreground. You may cancel task running this + method to stop the bot. + + Warning: calling `stop()` is not a supported way to stop the bot. You + should cancel this task instead. + """ + await self.start() + try: + await asyncio.Event().wait() + finally: + await self.stop() + def get_client(self) -> AsyncClient: """ Get AsyncClient.