change rule

This commit is contained in:
yanyongyu
2020-08-14 17:41:24 +08:00
parent 04f4d5028e
commit 1dcc43161a
13 changed files with 252 additions and 192 deletions

View File

@ -4,6 +4,7 @@
import abc
from ipaddress import IPv4Address
from nonebot.log import logger
from nonebot.config import Env, Config
from nonebot.typing import Bot, Dict, Type, Optional, Callable
@ -20,6 +21,7 @@ class BaseDriver(abc.ABC):
@classmethod
def register_adapter(cls, name: str, adapter: Type[Bot]):
cls._adapters[name] = adapter
logger.debug(f'Succeeded to load adapter "{name}"')
@property
@abc.abstractmethod

View File

@ -152,15 +152,16 @@ class Driver(BaseDriver):
await websocket.accept()
self._clients[x_self_id] = bot
while not websocket.closed:
data = await websocket.receive()
try:
while not websocket.closed:
data = await websocket.receive()
if not data:
continue
if not data:
continue
await bot.handle_message(data)
del self._clients[x_self_id]
await bot.handle_message(data)
finally:
del self._clients[x_self_id]
class WebSocket(BaseWebSocket):