🎨 change method into private

This commit is contained in:
yanyongyu 2020-12-28 13:59:54 +08:00
parent 0c43d83494
commit 1c9df5ac02
2 changed files with 4 additions and 4 deletions

View File

@ -153,7 +153,7 @@ class Driver(abc.ABC):
self._ws_disconnection_hook.add(func) self._ws_disconnection_hook.add(func)
return func return func
def bot_connect(self, bot: "Bot") -> None: def _bot_connect(self, bot: "Bot") -> None:
"""在 WebSocket 连接成功后,调用该函数来注册 bot 对象""" """在 WebSocket 连接成功后,调用该函数来注册 bot 对象"""
self._clients[bot.self_id] = bot self._clients[bot.self_id] = bot
@ -169,7 +169,7 @@ class Driver(abc.ABC):
asyncio.create_task(_run_hook(bot)) asyncio.create_task(_run_hook(bot))
def bot_disconnect(self, bot: "Bot") -> None: def _bot_disconnect(self, bot: "Bot") -> None:
"""在 WebSocket 连接断开后,调用该函数来注销 bot 对象""" """在 WebSocket 连接断开后,调用该函数来注销 bot 对象"""
if bot.self_id in self._clients: if bot.self_id in self._clients:
del self._clients[bot.self_id] del self._clients[bot.self_id]

View File

@ -192,7 +192,7 @@ class Driver(BaseDriver):
f"WebSocket Connection from <y>{adapter.upper()} " f"WebSocket Connection from <y>{adapter.upper()} "
f"Bot {x_self_id}</y> Accepted!") f"Bot {x_self_id}</y> Accepted!")
self.bot_connect(bot) self._bot_connect(bot)
try: try:
while not ws.closed: while not ws.closed:
@ -203,7 +203,7 @@ class Driver(BaseDriver):
asyncio.create_task(bot.handle_message(data)) asyncio.create_task(bot.handle_message(data))
finally: finally:
self.bot_disconnect(bot) self._bot_disconnect(bot)
class WebSocket(BaseWebSocket): class WebSocket(BaseWebSocket):