mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-24 09:05:04 +08:00
🎨 change method into private
This commit is contained in:
parent
0c43d83494
commit
1c9df5ac02
@ -153,7 +153,7 @@ class Driver(abc.ABC):
|
||||
self._ws_disconnection_hook.add(func)
|
||||
return func
|
||||
|
||||
def bot_connect(self, bot: "Bot") -> None:
|
||||
def _bot_connect(self, bot: "Bot") -> None:
|
||||
"""在 WebSocket 连接成功后,调用该函数来注册 bot 对象"""
|
||||
self._clients[bot.self_id] = bot
|
||||
|
||||
@ -169,7 +169,7 @@ class Driver(abc.ABC):
|
||||
|
||||
asyncio.create_task(_run_hook(bot))
|
||||
|
||||
def bot_disconnect(self, bot: "Bot") -> None:
|
||||
def _bot_disconnect(self, bot: "Bot") -> None:
|
||||
"""在 WebSocket 连接断开后,调用该函数来注销 bot 对象"""
|
||||
if bot.self_id in self._clients:
|
||||
del self._clients[bot.self_id]
|
||||
|
@ -192,7 +192,7 @@ class Driver(BaseDriver):
|
||||
f"WebSocket Connection from <y>{adapter.upper()} "
|
||||
f"Bot {x_self_id}</y> Accepted!")
|
||||
|
||||
self.bot_connect(bot)
|
||||
self._bot_connect(bot)
|
||||
|
||||
try:
|
||||
while not ws.closed:
|
||||
@ -203,7 +203,7 @@ class Driver(BaseDriver):
|
||||
|
||||
asyncio.create_task(bot.handle_message(data))
|
||||
finally:
|
||||
self.bot_disconnect(bot)
|
||||
self._bot_disconnect(bot)
|
||||
|
||||
|
||||
class WebSocket(BaseWebSocket):
|
||||
|
Loading…
Reference in New Issue
Block a user