diff --git a/nonebot/drivers/quart.py b/nonebot/drivers/quart.py index 3920cf13..ac8063d7 100644 --- a/nonebot/drivers/quart.py +++ b/nonebot/drivers/quart.py @@ -9,6 +9,7 @@ Quart 驱动适配 """ import asyncio +from dataclasses import dataclass from typing import List, TypeVar, Callable, Coroutine, Optional import uvicorn @@ -231,6 +232,7 @@ class Driver(ReverseDriver): self._bot_disconnect(bot) +@dataclass class WebSocket(BaseWebSocket): websocket: QuartWebSocket = None # type: ignore diff --git a/nonebot/plugins/single_session.py b/nonebot/plugins/single_session.py index 42df70d7..5124f7cb 100644 --- a/nonebot/plugins/single_session.py +++ b/nonebot/plugins/single_session.py @@ -9,7 +9,7 @@ _running_matcher: Dict[str, int] = {} @run_preprocessor -async def _(matcher: Matcher, bot: Bot, event: Event, state: T_State): +async def preprocess(matcher: Matcher, bot: Bot, event: Event, state: T_State): try: session_id = event.get_session_id() except Exception: @@ -23,7 +23,8 @@ async def _(matcher: Matcher, bot: Bot, event: Event, state: T_State): @run_postprocessor -async def _(matcher: Matcher, exception: Optional[Exception], bot: Bot, event: Event, state: T_State): +async def postprocess(matcher: Matcher, exception: Optional[Exception], + bot: Bot, event: Event, state: T_State): try: session_id = event.get_session_id() except Exception: diff --git a/tests/test_plugins/test_package/test_command.py b/tests/test_plugins/test_package/test_command.py index 3b77fb5e..9ffa3fbf 100644 --- a/tests/test_plugins/test_package/test_command.py +++ b/tests/test_plugins/test_package/test_command.py @@ -7,7 +7,7 @@ test_command = on_command("帮助", to_me()) @test_command.handle() -async def test_handler(bot: Bot, event: Event, state: T_State): +async def test_handler1(bot: Bot, event: Event, state: T_State): args = str(event.get_message()).strip() print("[!] Command:", state["_prefix"], "Args:", args) if args: @@ -17,7 +17,7 @@ async def test_handler(bot: Bot, event: Event, state: T_State): @test_command.got("help", prompt="你要帮助的命令是?") -async def test_handler(bot: Bot, event: Event, state: T_State): +async def test_handler2(bot: Bot, event: Event, state: T_State): print("[!] Command 帮助:", state["help"]) if state["help"] not in ["test1", "test2"]: await test_command.reject(f"{state['help']} 不支持,请重新输入!") diff --git a/tests/test_plugins/test_permission.py b/tests/test_plugins/test_permission.py index a7157dff..1f8b71d6 100644 --- a/tests/test_plugins/test_permission.py +++ b/tests/test_plugins/test_permission.py @@ -9,10 +9,10 @@ test_command = on_startswith("hello", to_me(), permission=SUPERUSER) @test_command.handle() -async def test_handler(bot: CQHTTPBot): +async def test_handler1(bot: CQHTTPBot): await test_command.finish("cqhttp hello") @test_command.handle() -async def test_handler(bot: DingBot): +async def test_handler2(bot: DingBot): await test_command.finish("ding hello")