🐛 fix builtin bug

This commit is contained in:
yanyongyu 2021-12-13 00:37:07 +08:00
parent 8f3978f2b2
commit e942f4076c
2 changed files with 9 additions and 8 deletions

View File

@ -156,7 +156,7 @@ class BotParam(Param):
): ):
return cls(Required) return cls(Required)
def _solve(self, bot: Bot, **kwargs: Any) -> Any: async def _solve(self, bot: Bot, **kwargs: Any) -> Any:
return bot return bot
@ -171,7 +171,7 @@ class EventParam(Param):
): ):
return cls(Required) return cls(Required)
def _solve(self, event: Event, **kwargs: Any) -> Any: async def _solve(self, event: Event, **kwargs: Any) -> Any:
return event return event
@ -191,7 +191,7 @@ class StateParam(Param):
if isinstance(param.default, StateInner): if isinstance(param.default, StateInner):
return cls(Required) return cls(Required)
def _solve(self, state: T_State, **kwargs: Any) -> Any: async def _solve(self, state: T_State, **kwargs: Any) -> Any:
return state return state
@ -205,7 +205,7 @@ class MatcherParam(Param):
): ):
return cls(Required) return cls(Required)
def _solve(self, matcher: "Matcher", **kwargs: Any) -> Any: async def _solve(self, matcher: "Matcher", **kwargs: Any) -> Any:
return matcher return matcher
@ -219,7 +219,7 @@ class ExceptionParam(Param):
): ):
return cls(Required) 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 return exception
@ -231,7 +231,7 @@ class DefaultParam(Param):
if param.default != param.empty: if param.default != param.empty:
return cls(param.default) return cls(param.default)
def _solve(self, **kwargs: Any) -> Any: async def _solve(self, **kwargs: Any) -> Any:
return Undefined return Undefined

View File

@ -4,6 +4,7 @@ import inspect
from types import ModuleType from types import ModuleType
from typing import Any, Set, Dict, List, Type, Tuple, Union, Optional from typing import Any, Set, Dict, List, Type, Tuple, Union, Optional
from nonebot.params import State
from nonebot.adapters import Event from nonebot.adapters import Event
from nonebot.matcher import Matcher from nonebot.matcher import Matcher
from .manager import _current_plugin from .manager import _current_plugin
@ -393,7 +394,7 @@ def on_command(
- ``Type[Matcher]`` - ``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() message = event.get_message()
if len(message) < 1: if len(message) < 1:
return return
@ -451,7 +452,7 @@ def on_shell_command(
- ``Type[Matcher]`` - ``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() message = event.get_message()
segment = message.pop(0) segment = message.pop(0)
new_message = message.__class__( new_message = message.__class__(