💡 update source docstring #46 #49

This commit is contained in:
yanyongyu
2020-11-13 01:46:26 +08:00
parent 5c29abd724
commit 28e3177e60
10 changed files with 160 additions and 77 deletions

View File

@ -1,6 +1,6 @@
"""
后端驱动适配基类
===============
=================
各驱动请继承以下基类
"""
@ -27,6 +27,7 @@ class BaseDriver(abc.ABC):
def __init__(self, env: Env, config: Config):
"""
:参数:
* ``env: Env``: 包含环境信息的 Env 对象
* ``config: Config``: 包含配置信息的 Config 对象
"""
@ -136,6 +137,7 @@ class BaseWebSocket(object):
def __init__(self, websocket):
"""
:参数:
* ``websocket: Any``: WebSocket 连接对象
"""
self._websocket = websocket

View File

@ -150,7 +150,7 @@ class Driver(BaseDriver):
detail=e.reason) from None
if x_self_id in self._clients:
logger.warning("There's already a reverse websocket api connection,"
logger.warning("There's already a reverse websocket connection,"
"so the event may be handled twice.")
bot = BotClass(self, "http", self.config, x_self_id)
@ -178,6 +178,11 @@ class Driver(BaseDriver):
await ws.close(code=status.WS_1008_POLICY_VIOLATION)
return
if x_self_id in self._clients:
logger.warning("There's already a reverse websocket connection, "
f"<y>{adapter.upper()} Bot {x_self_id}</y> ignored.")
await ws.close(code=status.WS_1008_POLICY_VIOLATION)
bot = BotClass(self, "websocket", self.config, x_self_id, websocket=ws)
await ws.accept()