mirror of
				https://github.com/nonebot/nonebot2.git
				synced 2025-10-31 06:56:39 +00:00 
			
		
		
		
	⚗️ add type and permission updater hook
This commit is contained in:
		| @@ -291,7 +291,7 @@ Event 基类。提供获取关键信息的方法,其余信息可直接获取 | ||||
|     * `Literal["message", "notice", "request", "meta_event"]` | ||||
|  | ||||
|  | ||||
|     * `str` | ||||
|     * 其他自定义 `str` | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -197,6 +197,36 @@ sidebarDepth: 0 | ||||
|  | ||||
|  | ||||
|  | ||||
| ### `_default_type_updater` | ||||
|  | ||||
|  | ||||
| * **类型** | ||||
|  | ||||
|     `Optional[T_ArgsParser]` | ||||
|  | ||||
|  | ||||
|  | ||||
| * **说明** | ||||
|  | ||||
|     事件响应器类型更新函数 | ||||
|  | ||||
|  | ||||
|  | ||||
| ### `_default_permission_updater` | ||||
|  | ||||
|  | ||||
| * **类型** | ||||
|  | ||||
|     `Optional[T_ArgsParser]` | ||||
|  | ||||
|  | ||||
|  | ||||
| * **说明** | ||||
|  | ||||
|     事件响应器权限更新函数 | ||||
|  | ||||
|  | ||||
|  | ||||
| ### `__init__()` | ||||
|  | ||||
| 实例化 Matcher 以便运行 | ||||
| @@ -341,6 +371,38 @@ sidebarDepth: 0 | ||||
|  | ||||
|  | ||||
|  | ||||
| ### _classmethod_ `type_updater(func)` | ||||
|  | ||||
|  | ||||
| * **说明** | ||||
|  | ||||
|     装饰一个函数来更改当前事件响应器的默认响应事件类型更新函数 | ||||
|  | ||||
|  | ||||
|  | ||||
| * **参数** | ||||
|  | ||||
|      | ||||
|     * `func: T_TypeUpdater`: 响应事件类型更新函数 | ||||
|  | ||||
|  | ||||
|  | ||||
| ### _classmethod_ `permission_updater(func)` | ||||
|  | ||||
|  | ||||
| * **说明** | ||||
|  | ||||
|     装饰一个函数来更改当前事件响应器的默认会话权限更新函数 | ||||
|  | ||||
|  | ||||
|  | ||||
| * **参数** | ||||
|  | ||||
|      | ||||
|     * `func: T_PermissionUpdater`: 会话权限更新函数 | ||||
|  | ||||
|  | ||||
|  | ||||
| ### _classmethod_ `handle()` | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -212,3 +212,35 @@ sidebarDepth: 0 | ||||
| * **说明** | ||||
|  | ||||
|     ArgsParser 即消息参数解析函数,在 Matcher.got 获取参数时被运行。 | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ## `T_TypeUpdater` | ||||
|  | ||||
|  | ||||
| * **类型** | ||||
|  | ||||
|     `Callable[[Bot, Event, T_State, str], Awaitable[str]]` | ||||
|  | ||||
|  | ||||
|  | ||||
| * **说明** | ||||
|  | ||||
|     TypeUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新响应的事件类型。默认会更新为 `message`。 | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ## `T_PermissionUpdater` | ||||
|  | ||||
|  | ||||
| * **类型** | ||||
|  | ||||
|     `Callable[[Bot, Event, T_State, Permission], Awaitable[Permission]]` | ||||
|  | ||||
|  | ||||
|  | ||||
| * **说明** | ||||
|  | ||||
|     PermissionUpdater 在 Matcher.pause, Matcher.reject 时被运行,用于更新会话对象权限。默认会更新为当前事件的触发对象。 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user