smal: allow the bot to start without sync
This commit is contained in:
parent
7ed8e1c186
commit
ccf426e8b0
1 changed files with 5 additions and 4 deletions
|
|
@ -30,17 +30,18 @@ class SMALApp(_AsyncClient):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def run(self):
|
def run(self, sync=True):
|
||||||
asyncio.run(self.main_loop())
|
asyncio.run(self.main_loop(sync))
|
||||||
|
|
||||||
async def main_loop(self):
|
async def main_loop(self, sync):
|
||||||
if hasattr(self, "on_startup") and callable(self.on_startup):
|
if hasattr(self, "on_startup") and callable(self.on_startup):
|
||||||
await self.on_startup()
|
await self.on_startup()
|
||||||
|
|
||||||
if hasattr(self, "on_startup_run") and callable(self.on_startup_run):
|
if hasattr(self, "on_startup_run") and callable(self.on_startup_run):
|
||||||
await asyncio.ensure_future(self.on_startup_run())
|
await asyncio.ensure_future(self.on_startup_run())
|
||||||
|
|
||||||
await self._sync()
|
if sync:
|
||||||
|
await self._sync()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._stopsync()
|
self._stopsync()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue