From e942f4076c045ccb84d29b246bcc7074cb9c50f3 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Mon, 13 Dec 2021 00:37:07 +0800 Subject: [PATCH] :bug: fix builtin bug --- nonebot/params.py | 12 ++++++------ nonebot/plugin/on.py | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/nonebot/params.py b/nonebot/params.py index b92e9a15..4023f03d 100644 --- a/nonebot/params.py +++ b/nonebot/params.py @@ -156,7 +156,7 @@ class BotParam(Param): ): return cls(Required) - def _solve(self, bot: Bot, **kwargs: Any) -> Any: + async def _solve(self, bot: Bot, **kwargs: Any) -> Any: return bot @@ -171,7 +171,7 @@ class EventParam(Param): ): return cls(Required) - def _solve(self, event: Event, **kwargs: Any) -> Any: + async def _solve(self, event: Event, **kwargs: Any) -> Any: return event @@ -191,7 +191,7 @@ class StateParam(Param): if isinstance(param.default, StateInner): return cls(Required) - def _solve(self, state: T_State, **kwargs: Any) -> Any: + async def _solve(self, state: T_State, **kwargs: Any) -> Any: return state @@ -205,7 +205,7 @@ class MatcherParam(Param): ): return cls(Required) - def _solve(self, matcher: "Matcher", **kwargs: Any) -> Any: + async def _solve(self, matcher: "Matcher", **kwargs: Any) -> Any: return matcher @@ -219,7 +219,7 @@ class ExceptionParam(Param): ): return cls(Required) - def _solve(self, exception: Optional[Exception] = None, **kwargs: Any) -> Any: + async def _solve(self, exception: Optional[Exception] = None, **kwargs: Any) -> Any: return exception @@ -231,7 +231,7 @@ class DefaultParam(Param): if param.default != param.empty: return cls(param.default) - def _solve(self, **kwargs: Any) -> Any: + async def _solve(self, **kwargs: Any) -> Any: return Undefined diff --git a/nonebot/plugin/on.py b/nonebot/plugin/on.py index f0a5523c..5f65a21b 100644 --- a/nonebot/plugin/on.py +++ b/nonebot/plugin/on.py @@ -4,6 +4,7 @@ import inspect from types import ModuleType from typing import Any, Set, Dict, List, Type, Tuple, Union, Optional +from nonebot.params import State from nonebot.adapters import Event from nonebot.matcher import Matcher from .manager import _current_plugin @@ -393,7 +394,7 @@ def on_command( - ``Type[Matcher]`` """ - async def _strip_cmd(event: Event, state: T_State): + async def _strip_cmd(event: Event, state: T_State = State()): message = event.get_message() if len(message) < 1: return @@ -451,7 +452,7 @@ def on_shell_command( - ``Type[Matcher]`` """ - async def _strip_cmd(event: Event, state: T_State): + async def _strip_cmd(event: Event, state: T_State = State()): message = event.get_message() segment = message.pop(0) new_message = message.__class__(