⚗️ add type and permission updater hook

This commit is contained in:
yanyongyu
2021-03-03 16:06:19 +08:00
parent 464f0d4a89
commit 9e04e497b7
7 changed files with 200 additions and 29 deletions

View File

@ -21,8 +21,9 @@ from collections.abc import Callable as BaseCallable
from typing import Any, Dict, Union, TypeVar, Optional, Callable, NoReturn, Awaitable, TYPE_CHECKING
if TYPE_CHECKING:
from nonebot.adapters import Bot, Event
from nonebot.matcher import Matcher
from nonebot.adapters import Bot, Event
from nonebot.permission import Permission
T_Wrapped = TypeVar("T_Wrapped", bound=BaseCallable)
@ -152,3 +153,20 @@ T_ArgsParser = Callable[["Bot", "Event", T_State], Union[Awaitable[None],
ArgsParser 即消息参数解析函数,在 Matcher.got 获取参数时被运行。
"""
T_TypeUpdater = Callable[["Bot", "Event", T_State, str], Awaitable[str]]
"""
:类型: ``Callable[[Bot, Event, T_State, str], Awaitable[str]]``
:说明:
TypeUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新响应的事件类型。默认会更新为 ``message``。
"""
T_PermissionUpdater = Callable[["Bot", "Event", T_State, "Permission"],
Awaitable["Permission"]]
"""
:类型: ``Callable[[Bot, Event, T_State, Permission], Awaitable[Permission]]``
:说明:
PermissionUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新会话对象权限。默认会更新为当前事件的触发对象。
"""