mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-09-06 20:16:47 +00:00
@ -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
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user