Added MatrixBot.run() for dev simplification
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from typing import Callable, Coroutine, Any
|
from typing import Callable, Coroutine, Any
|
||||||
@@ -97,6 +98,20 @@ class MatrixBot:
|
|||||||
"""
|
"""
|
||||||
await self._client_manager.stop()
|
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:
|
def get_client(self) -> AsyncClient:
|
||||||
"""
|
"""
|
||||||
Get AsyncClient.
|
Get AsyncClient.
|
||||||
|
|||||||
Reference in New Issue
Block a user