Skip to content

Commit

Permalink
Merge pull request #26 from T0nyX1ang/master
Browse files Browse the repository at this point in the history
Feature: 优化 Bot 连接与断开时机
  • Loading branch information
RF-Tar-Railt authored Nov 17, 2023
2 parents 2365ffa + 96d0dd4 commit 70c1b0c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 0 additions & 2 deletions nonebot/adapters/console/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ async def _start(self) -> None:
)
self._frontend.backend.set_adapter(self)
self._task = asyncio.create_task(self._frontend.run_async())
self.bot_connect(self.bot)

async def _shutdown(self) -> None:
self.bot_disconnect(self.bot)
if self._frontend:
self._frontend.exit()
if self._task:
Expand Down
6 changes: 4 additions & 2 deletions nonebot/adapters/console/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def on_console_load(self):
)

def on_console_mount(self):
pass
self._adapter.bot_connect(self._adapter.bot)
logger.success("Console mounted.")

def on_console_unmount(self):
if self._logger_id is not None:
Expand All @@ -61,7 +62,8 @@ def on_console_unmount(self):
format=default_format,
)
self._should_restore_logger = False
logger.success("Console exit.")
self._adapter.bot_disconnect(self._adapter.bot)
logger.success("Console unmounted.")
logger.warning("Press Ctrl-C for Application exit")

async def post_event(self, event: ConsoleEvent):
Expand Down

0 comments on commit 70c1b0c

Please sign in to comment.