From 5b3ef53301ee3b125595fb7b0eda653625326b7d Mon Sep 17 00:00:00 2001 From: Mix Date: Sat, 30 Jan 2021 13:45:55 +0800 Subject: [PATCH] :art: add support for on_bot_* event handler --- nonebot/adapters/mirai/bot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nonebot/adapters/mirai/bot.py b/nonebot/adapters/mirai/bot.py index 70166eff..08f6ea4e 100644 --- a/nonebot/adapters/mirai/bot.py +++ b/nonebot/adapters/mirai/bot.py @@ -121,6 +121,8 @@ class MiraiBot(BaseBot): def __init__(self, connection_type: str, self_id: str, *, websocket: WebSocket): super().__init__(connection_type, self_id, websocket=websocket) + websocket.handle(self.handle_message) + self.driver._bot_connect(self) @property @overrides(BaseBot) @@ -213,3 +215,6 @@ class MiraiBot(BaseBot): @overrides(BaseBot) async def send(self, event: "BaseEvent", message: str, **kwargs): return super().send(event, message, **kwargs) + + def __del__(self): + self.driver._bot_disconnect(self)