🐛 matcher.send returned none

This commit is contained in:
yanyongyu 2021-03-24 00:28:37 +08:00
parent 48fae782d7
commit f00ce8b4f6
2 changed files with 13 additions and 9 deletions

View File

@ -109,7 +109,7 @@ class Bot(abc.ABC):
raise NotImplementedError raise NotImplementedError
@abc.abstractmethod @abc.abstractmethod
async def call_api(self, api: str, **data): async def call_api(self, api: str, **data) -> Any:
""" """
:说明: :说明:
@ -130,8 +130,9 @@ class Bot(abc.ABC):
raise NotImplementedError raise NotImplementedError
@abc.abstractmethod @abc.abstractmethod
async def send(self, event: "Event", async def send(self, event: "Event", message: Union[str, "Message",
message: Union[str, "Message", "MessageSegment"], **kwargs): "MessageSegment"],
**kwargs) -> Any:
""" """
:说明: :说明:

View File

@ -9,14 +9,17 @@ from functools import wraps
from datetime import datetime from datetime import datetime
from contextvars import ContextVar from contextvars import ContextVar
from collections import defaultdict from collections import defaultdict
from typing import Type, List, Dict, Union, Mapping, Iterable, Callable, Optional, NoReturn, TYPE_CHECKING from typing import (Any, Type, List, Dict, Union, Mapping, Iterable, Callable,
Optional, NoReturn, TYPE_CHECKING)
from nonebot.rule import Rule from nonebot.rule import Rule
from nonebot.log import logger from nonebot.log import logger
from nonebot.handler import Handler from nonebot.handler import Handler
from nonebot.permission import Permission, USER from nonebot.permission import Permission, USER
from nonebot.typing import T_State, T_StateFactory, T_Handler, T_ArgsParser, T_TypeUpdater, T_PermissionUpdater from nonebot.typing import (T_State, T_StateFactory, T_Handler, T_ArgsParser,
from nonebot.exception import PausedException, RejectedException, FinishedException, StopPropagation T_TypeUpdater, T_PermissionUpdater)
from nonebot.exception import (PausedException, RejectedException,
FinishedException, StopPropagation)
if TYPE_CHECKING: if TYPE_CHECKING:
from nonebot.adapters import Bot, Event, Message, MessageSegment from nonebot.adapters import Bot, Event, Message, MessageSegment
@ -437,7 +440,7 @@ class Matcher(metaclass=MatcherMeta):
@classmethod @classmethod
async def send(cls, message: Union[str, "Message", "MessageSegment"], async def send(cls, message: Union[str, "Message", "MessageSegment"],
**kwargs): **kwargs) -> Any:
""" """
:说明: :说明:
@ -448,9 +451,9 @@ class Matcher(metaclass=MatcherMeta):
* ``message: Union[str, Message, MessageSegment]``: 消息内容 * ``message: Union[str, Message, MessageSegment]``: 消息内容
* ``**kwargs``: 其他传递给 ``bot.send`` 的参数请参考对应 adapter bot 对象 api * ``**kwargs``: 其他传递给 ``bot.send`` 的参数请参考对应 adapter bot 对象 api
""" """
bot = current_bot.get() bot: "Bot" = current_bot.get()
event = current_event.get() event = current_event.get()
await bot.send(event=event, message=message, **kwargs) return await bot.send(event=event, message=message, **kwargs)
@classmethod @classmethod
async def finish(cls, async def finish(cls,