Added MatrixBot.run() for dev simplification

This commit is contained in:
2026-09-12 18:06:55 +03:00
parent b8e598715c
commit 3e15ae426c

View File

@@ -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.