mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-27 16:21:28 +00:00
🔖 Release 2.0.0-beta.2
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
{
|
||||
"position": 12
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
description: nonebot.plugin.export 模块
|
||||
---
|
||||
|
||||
# nonebot.plugin.export
|
||||
|
||||
本模块定义了插件导出的内容对象。
|
||||
|
||||
在新版插件系统中,推荐优先使用直接 import 所需要的插件内容。
|
||||
|
||||
## _class_ `Export()` {#Export}
|
||||
|
||||
- **说明**
|
||||
|
||||
插件导出内容以使得其他插件可以获得。
|
||||
|
||||
- **用法**
|
||||
|
||||
```python
|
||||
nonebot.export().default = "bar"
|
||||
|
||||
@nonebot.export()
|
||||
def some_function():
|
||||
pass
|
||||
|
||||
# this doesn't work before python 3.9
|
||||
# use
|
||||
# export = nonebot.export(); @export.sub
|
||||
# instead
|
||||
# See also PEP-614: https://www.python.org/dev/peps/pep-0614/
|
||||
@nonebot.export().sub
|
||||
def something_else():
|
||||
pass
|
||||
```
|
||||
|
||||
## _def_ `export()` {#export}
|
||||
|
||||
- **说明**
|
||||
|
||||
获取当前插件的导出内容对象
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Export](#Export)
|
@ -0,0 +1,37 @@
|
||||
---
|
||||
sidebar_position: 0
|
||||
description: nonebot.plugin 模块
|
||||
---
|
||||
|
||||
# nonebot.plugin
|
||||
|
||||
本模块为 NoneBot 插件开发提供便携的定义函数。
|
||||
|
||||
## 快捷导入
|
||||
|
||||
为方便使用,本模块从子模块导入了部分内容,以下内容可以直接通过本模块导入:
|
||||
|
||||
- `on` => [`on`](./on.md#on)
|
||||
- `on_metaevent` => [`on_metaevent`](./on.md#on_metaevent)
|
||||
- `on_message` => [`on_message`](./on.md#on_message)
|
||||
- `on_notice` => [`on_notice`](./on.md#on_notice)
|
||||
- `on_request` => [`on_request`](./on.md#on_request)
|
||||
- `on_startswith` => [`on_startswith`](./on.md#on_startswith)
|
||||
- `on_endswith` => [`on_endswith`](./on.md#on_endswith)
|
||||
- `on_keyword` => [`on_keyword`](./on.md#on_keyword)
|
||||
- `on_command` => [`on_command`](./on.md#on_command)
|
||||
- `on_shell_command` => [`on_shell_command`](./on.md#on_shell_command)
|
||||
- `on_regex` => [`on_regex`](./on.md#on_regex)
|
||||
- `CommandGroup` => [`CommandGroup`](./on.md#CommandGroup)
|
||||
- `Matchergroup` => [`MatcherGroup`](./on.md#MatcherGroup)
|
||||
- `load_plugin` => [`load_plugin`](./load.md#load_plugin)
|
||||
- `load_plugins` => [`load_plugins`](./load.md#load_plugins)
|
||||
- `load_all_plugins` => [`load_all_plugins`](./load.md#load_all_plugins)
|
||||
- `load_from_json` => [`load_from_json`](./load.md#load_from_json)
|
||||
- `load_from_toml` => [`load_from_toml`](./load.md#load_from_toml)
|
||||
- `load_builtin_plugin` => [`load_builtin_plugin`](./load.md#load_builtin_plugin)
|
||||
- `load_builtin_plugins` => [`load_builtin_plugins`](./load.md#load_builtin_plugins)
|
||||
- `get_plugin` => [`get_plugin`](./plugin.md#get_plugin)
|
||||
- `get_loaded_plugins` => [`get_loaded_plugins`](./plugin.md#get_loaded_plugins)
|
||||
- `export` => [`export`](./export.md#export)
|
||||
- `require` => [`require`](./load.md#require)
|
157
website/versioned_docs/version-2.0.0-beta.2/api/plugin/load.md
Normal file
157
website/versioned_docs/version-2.0.0-beta.2/api/plugin/load.md
Normal file
@ -0,0 +1,157 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
description: nonebot.plugin.load 模块
|
||||
---
|
||||
|
||||
# nonebot.plugin.load
|
||||
|
||||
本模块定义插件加载接口。
|
||||
|
||||
## _def_ `load_plugin(module_path)` {#load_plugin}
|
||||
|
||||
- **说明**
|
||||
|
||||
加载单个插件,可以是本地插件或是通过 `pip` 安装的插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `module_path` (str): 插件名称 `path.to.your.plugin`
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](./plugin.md#Plugin) | None
|
||||
|
||||
## _def_ `load_plugins(*plugin_dir)` {#load_plugins}
|
||||
|
||||
- **说明**
|
||||
|
||||
导入文件夹下多个插件,以 `_` 开头的插件不会被导入!
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*plugin_dir` (str): 文件夹路径
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](./plugin.md#Plugin)]
|
||||
|
||||
## _def_ `load_all_plugins(module_path, plugin_dir)` {#load_all_plugins}
|
||||
|
||||
- **说明**
|
||||
|
||||
导入指定列表中的插件以及指定目录下多个插件,以 `_` 开头的插件不会被导入!
|
||||
|
||||
- **参数**
|
||||
|
||||
- `module_path` (Iterable[str]): 指定插件集合
|
||||
|
||||
- `plugin_dir` (Iterable[str]): 指定文件夹路径集合
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](./plugin.md#Plugin)]
|
||||
|
||||
## _def_ `load_from_json(file_path, encoding='utf-8')` {#load_from_json}
|
||||
|
||||
- **说明**
|
||||
|
||||
导入指定 json 文件中的 `plugins` 以及 `plugin_dirs` 下多个插件,以 `_` 开头的插件不会被导入!
|
||||
|
||||
- **参数**
|
||||
|
||||
- `file_path` (str): 指定 json 文件路径
|
||||
|
||||
- `encoding` (str): 指定 json 文件编码
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](./plugin.md#Plugin)]
|
||||
|
||||
- **用法**
|
||||
|
||||
```json title=plugins.json
|
||||
{
|
||||
"plugins": ["some_plugin"],
|
||||
"plugin_dirs": ["some_dir"]
|
||||
}
|
||||
```
|
||||
|
||||
```python
|
||||
nonebot.load_from_json("plugins.json")
|
||||
```
|
||||
|
||||
## _def_ `load_from_toml(file_path, encoding='utf-8')` {#load_from_toml}
|
||||
|
||||
- **说明**
|
||||
|
||||
导入指定 toml 文件 `[tool.nonebot]` 中的 `plugins` 以及 `plugin_dirs` 下多个插件,以 `_` 开头的插件不会被导入!
|
||||
|
||||
- **参数**
|
||||
|
||||
- `file_path` (str): 指定 toml 文件路径
|
||||
|
||||
- `encoding` (str): 指定 toml 文件编码
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](./plugin.md#Plugin)]
|
||||
|
||||
- **用法**
|
||||
|
||||
```toml title=pyproject.toml
|
||||
[tool.nonebot]
|
||||
plugins = ["some_plugin"]
|
||||
plugin_dirs = ["some_dir"]
|
||||
```
|
||||
|
||||
```python
|
||||
nonebot.load_from_toml("pyproject.toml")
|
||||
```
|
||||
|
||||
## _def_ `load_builtin_plugin(name)` {#load_builtin_plugin}
|
||||
|
||||
- **说明**
|
||||
|
||||
导入 NoneBot 内置插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str): 插件名称
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](./plugin.md#Plugin) | None
|
||||
|
||||
## _def_ `load_builtin_plugins(*plugins)` {#load_builtin_plugins}
|
||||
|
||||
- **说明**
|
||||
|
||||
导入多个 NoneBot 内置插件。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `*plugins`: 插件名称列表
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](./plugin.md#Plugin)]
|
||||
|
||||
## _def_ `require(name)` {#require}
|
||||
|
||||
- **说明**
|
||||
|
||||
获取一个插件的导出内容。
|
||||
|
||||
如果为 `load_plugins` 文件夹导入的插件,则为文件(夹)名。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str): 插件名,即 [Plugin.name](./plugin.md#Plugin-name)。
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Export](./export.md#Export)
|
||||
|
||||
- **异常**
|
||||
|
||||
- `RuntimeError`: 插件无法加载
|
@ -0,0 +1,86 @@
|
||||
---
|
||||
sidebar_position: 5
|
||||
description: nonebot.plugin.manager 模块
|
||||
---
|
||||
|
||||
# nonebot.plugin.manager
|
||||
|
||||
本模块实现插件加载流程。
|
||||
|
||||
参考: [import hooks](https://docs.python.org/3/reference/import.html#import-hooks), [PEP302](https://www.python.org/dev/peps/pep-0302/)
|
||||
|
||||
## _class_ `PluginManager(plugins=None, search_path=None)` {#PluginManager}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `plugins` (Iterable[str] | None)
|
||||
|
||||
- `search_path` (Iterable[str] | None)
|
||||
|
||||
### _method_ `list_plugins(self)` {#PluginManager-list_plugins}
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[str]
|
||||
|
||||
### _method_ `load_all_plugins(self)` {#PluginManager-load_all_plugins}
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](./plugin.md#Plugin)]
|
||||
|
||||
### _method_ `load_plugin(self, name)` {#PluginManager-load_plugin}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](./plugin.md#Plugin) | None
|
||||
|
||||
## _class_ `PluginFinder()` {#PluginFinder}
|
||||
|
||||
### _method_ `find_spec(self, fullname, path, target=None)` {#PluginFinder-find_spec}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `fullname` (str)
|
||||
|
||||
- `path` (Sequence[bytes | str] | None)
|
||||
|
||||
- `target` (module | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Unknown
|
||||
|
||||
## _class_ `PluginLoader(manager, fullname, path)` {#PluginLoader}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `manager` ([PluginManager](#PluginManager))
|
||||
|
||||
- `fullname` (str)
|
||||
|
||||
- `path`
|
||||
|
||||
### _method_ `create_module(self, spec)` {#PluginLoader-create_module}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `spec`
|
||||
|
||||
- **返回**
|
||||
|
||||
- module | None
|
||||
|
||||
### _method_ `exec_module(self, module)` {#PluginLoader-exec_module}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `module` (module)
|
||||
|
||||
- **返回**
|
||||
|
||||
- None
|
766
website/versioned_docs/version-2.0.0-beta.2/api/plugin/on.md
Normal file
766
website/versioned_docs/version-2.0.0-beta.2/api/plugin/on.md
Normal file
@ -0,0 +1,766 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
description: nonebot.plugin.on 模块
|
||||
---
|
||||
|
||||
# nonebot.plugin.on
|
||||
|
||||
本模块定义事件响应器便携定义函数。
|
||||
|
||||
## _def_ `on(type='', rule=..., permission=..., *, handlers=..., temp=..., priority=..., block=..., state=...)` {#on}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个基础事件响应器,可自定义类型。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type` (str): 事件响应器类型
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
## _def_ `on_metaevent(rule=..., *, handlers=..., temp=..., priority=..., block=..., state=...)` {#on_metaevent}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个元事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
## _def_ `on_message(rule=..., permission=..., *, handlers=..., temp=..., priority=..., block=..., state=...)` {#on_message}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个消息事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
## _def_ `on_notice(rule=..., *, handlers=..., temp=..., priority=..., block=..., state=...)` {#on_notice}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个通知事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
## _def_ `on_request(rule=..., *, handlers=..., temp=..., priority=..., block=..., state=...)` {#on_request}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个请求事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
## _def_ `on_startswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_startswith}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息开头内容
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
## _def_ `on_endswith(msg, rule=..., ignorecase=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_endswith}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息结尾内容
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
## _def_ `on_keyword(keywords, rule=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_keyword}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `keywords` (set[str]): 关键词列表
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
## _def_ `on_command(cmd, rule=..., aliases=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_command}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个消息事件响应器,并且当消息以指定命令开头时响应。
|
||||
|
||||
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
## _def_ `on_shell_command(cmd, rule=..., aliases=..., parser=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_shell_command}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个支持 `shell_like` 解析参数的命令消息事件响应器。
|
||||
|
||||
与普通的 `on_command` 不同的是,在添加 `parser` 参数时, 响应器会自动处理消息。
|
||||
|
||||
并将用户输入的原始参数列表保存在 `state["argv"]`, `parser` 处理的参数保存在 `state["args"]` 中
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名
|
||||
|
||||
- `parser` ([ArgumentParser](../rule.md#ArgumentParser) | None): `nonebot.rule.ArgumentParser` 对象
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
## _def_ `on_regex(pattern, flags=..., rule=..., *, permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#on_regex}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个消息事件响应器,并且当消息匹配正则表达式时响应。
|
||||
|
||||
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `pattern` (str): 正则表达式
|
||||
|
||||
- `flags` (int | re.RegexFlag): 正则匹配标志
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
## _class_ `CommandGroup(cmd, *, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#CommandGroup}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...])
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType)
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType)
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None)
|
||||
|
||||
- `temp` (bool)
|
||||
|
||||
- `priority` (int)
|
||||
|
||||
- `block` (bool)
|
||||
|
||||
- `state` (dict[Any, Any] | None)
|
||||
|
||||
### _instance-var_ `basecmd` {#CommandGroup-basecmd}
|
||||
|
||||
- **类型:**
|
||||
|
||||
- **说明:** 命令前缀
|
||||
|
||||
### _instance-var_ `base_kwargs` {#CommandGroup-base_kwargs}
|
||||
|
||||
- **类型:**
|
||||
|
||||
- **说明:** 其他传递给 `on_command` 的参数默认值
|
||||
|
||||
### _method_ `command(self, cmd, *, aliases, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#CommandGroup-command}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个新的命令。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 命令前缀
|
||||
|
||||
\*\*kwargs: `on_command` 的参数,将会覆盖命令组默认值
|
||||
|
||||
- `aliases` (set[str | tuple[str, ...]] | None)
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType)
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType)
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None)
|
||||
|
||||
- `temp` (bool)
|
||||
|
||||
- `priority` (int)
|
||||
|
||||
- `block` (bool)
|
||||
|
||||
- `state` (dict[Any, Any] | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
### _method_ `shell_command(self, cmd, *, rule=..., aliases, parser=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#CommandGroup-shell_command}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个新的命令。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 命令前缀
|
||||
|
||||
\*\*kwargs: `on_shell_command` 的参数,将会覆盖命令组默认值
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType)
|
||||
|
||||
- `aliases` (set[str | tuple[str, ...]] | None)
|
||||
|
||||
- `parser` ([ArgumentParser](../rule.md#ArgumentParser) | None)
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType)
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None)
|
||||
|
||||
- `temp` (bool)
|
||||
|
||||
- `priority` (int)
|
||||
|
||||
- `block` (bool)
|
||||
|
||||
- `state` (dict[Any, Any] | None)
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
## _class_ `MatcherGroup(*, type=..., rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup}
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type` (str)
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType)
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType)
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None)
|
||||
|
||||
- `temp` (bool)
|
||||
|
||||
- `priority` (int)
|
||||
|
||||
- `block` (bool)
|
||||
|
||||
- `state` (dict[Any, Any] | None)
|
||||
|
||||
### _instance-var_ `matchers` {#MatcherGroup-matchers}
|
||||
|
||||
- **类型:**
|
||||
|
||||
- **说明:** 组内事件响应器列表
|
||||
|
||||
### _instance-var_ `base_kwargs` {#MatcherGroup-base_kwargs}
|
||||
|
||||
- **类型:**
|
||||
|
||||
- **说明:** 其他传递给 `on` 的参数默认值
|
||||
|
||||
### _method_ `on(self, *, type=..., rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个基础事件响应器,可自定义类型。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `type` (str): 事件响应器类型
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
### _method_ `on_command(self, cmd, aliases=..., *, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_command}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个消息事件响应器,并且当消息以指定命令开头时响应。
|
||||
|
||||
命令匹配规则参考: `命令形式匹配 <rule.md#command-command>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
### _method_ `on_endswith(self, msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_endswith}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个消息事件响应器,并且当消息的**文本部分**以指定内容结尾时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息结尾内容
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
### _method_ `on_keyword(self, keywords, *, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_keyword}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个消息事件响应器,并且当消息纯文本部分包含关键词时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `keywords` (set[str]): 关键词列表
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
### _method_ `on_message(self, *, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_message}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个消息事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
### _method_ `on_metaevent(self, *, rule=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_metaevent}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个元事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
### _method_ `on_notice(self, *, rule=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_notice}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个通知事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
### _method_ `on_regex(self, pattern, flags=..., *, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_regex}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个消息事件响应器,并且当消息匹配正则表达式时响应。
|
||||
|
||||
命令匹配规则参考: `正则匹配 <rule.md#regex-regex-flags-0>`\_
|
||||
|
||||
- **参数**
|
||||
|
||||
- `pattern` (str): 正则表达式
|
||||
|
||||
- `flags` (int | re.RegexFlag): 正则匹配标志
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
### _method_ `on_request(self, *, rule=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_request}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个请求事件响应器。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
### _method_ `on_shell_command(self, cmd, aliases=..., parser=..., *, rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_shell_command}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个支持 `shell_like` 解析参数的命令消息事件响应器。
|
||||
|
||||
与普通的 `on_command` 不同的是,在添加 `parser` 参数时, 响应器会自动处理消息。
|
||||
|
||||
并将用户输入的原始参数列表保存在 `state["argv"]`, `parser` 处理的参数保存在 `state["args"]` 中
|
||||
|
||||
- **参数**
|
||||
|
||||
- `cmd` (str | tuple[str, ...]): 指定命令内容
|
||||
|
||||
- `aliases` (set[str | tuple[str, ...]] | None): 命令别名
|
||||
|
||||
- `parser` ([ArgumentParser](../rule.md#ArgumentParser) | None): `nonebot.rule.ArgumentParser` 对象
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
||||
|
||||
### _method_ `on_startswith(self, msg, *, ignorecase=..., rule=..., permission=..., handlers=..., temp=..., priority=..., block=..., state=...)` {#MatcherGroup-on_startswith}
|
||||
|
||||
- **说明**
|
||||
|
||||
注册一个消息事件响应器,并且当消息的**文本部分**以指定内容开头时响应。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `msg` (str | tuple[str, ...]): 指定消息开头内容
|
||||
|
||||
- `ignorecase` (bool): 是否忽略大小写
|
||||
|
||||
- `rule` (nonebot.internal.rule.Rule | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应规则
|
||||
|
||||
- `permission` (nonebot.internal.permission.Permission | (\*Any, \*\*Any) -> bool | Awaitable[bool] | NoneType): 事件响应权限
|
||||
|
||||
- `handlers` (list[(\*Any, \*\*Any) -> Any | [Dependent](../dependencies/index.md#Dependent)] | None): 事件处理函数列表
|
||||
|
||||
- `temp` (bool): 是否为临时事件响应器(仅执行一次)
|
||||
|
||||
- `priority` (int): 事件响应器优先级
|
||||
|
||||
- `block` (bool): 是否阻止事件向更低优先级传递
|
||||
|
||||
- `state` (dict[Any, Any] | None): 默认 state
|
||||
|
||||
- **返回**
|
||||
|
||||
- Type[nonebot.internal.matcher.Matcher]
|
112
website/versioned_docs/version-2.0.0-beta.2/api/plugin/plugin.md
Normal file
112
website/versioned_docs/version-2.0.0-beta.2/api/plugin/plugin.md
Normal file
@ -0,0 +1,112 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
description: nonebot.plugin.plugin 模块
|
||||
---
|
||||
|
||||
# nonebot.plugin.plugin
|
||||
|
||||
本模块定义插件对象。
|
||||
|
||||
## _var_ `plugins` {#plugins}
|
||||
|
||||
- **类型:** dict[str, Plugin]
|
||||
|
||||
- **说明:** 已加载的插件
|
||||
|
||||
## _class_ `Plugin(name, module, module_name, manager, export=<factory>, matcher=<factory>, parent_plugin=None, sub_plugins=<factory>)` {#Plugin}
|
||||
|
||||
- **说明**
|
||||
|
||||
存储插件信息
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str)
|
||||
|
||||
- `module` (module)
|
||||
|
||||
- `module_name` (str)
|
||||
|
||||
- `manager` (PluginManager)
|
||||
|
||||
- `export` ([Export](./export.md#Export))
|
||||
|
||||
- `matcher` (set[Type[nonebot.internal.matcher.Matcher]])
|
||||
|
||||
- `parent_plugin` (Plugin | None)
|
||||
|
||||
- `sub_plugins` (set[Plugin])
|
||||
|
||||
### _class-var_ `parent_plugin` {#Plugin-parent_plugin}
|
||||
|
||||
- **类型:** Plugin | None
|
||||
|
||||
- **说明:** 父插件
|
||||
|
||||
### _instance-var_ `name` {#Plugin-name}
|
||||
|
||||
- **类型:** str
|
||||
|
||||
- **说明:** 插件名称,使用 文件/文件夹 名称作为插件名
|
||||
|
||||
### _instance-var_ `module` {#Plugin-module}
|
||||
|
||||
- **类型:** module
|
||||
|
||||
- **说明:** 插件模块对象
|
||||
|
||||
### _instance-var_ `module_name` {#Plugin-module_name}
|
||||
|
||||
- **类型:** str
|
||||
|
||||
- **说明:** 点分割模块路径
|
||||
|
||||
### _instance-var_ `manager` {#Plugin-manager}
|
||||
|
||||
- **类型:** PluginManager
|
||||
|
||||
- **说明:** 导入该插件的插件管理器
|
||||
|
||||
### _instance-var_ `export` {#Plugin-export}
|
||||
|
||||
- **类型:** nonebot.plugin.export.Export
|
||||
|
||||
- **说明:** 插件内定义的导出内容
|
||||
|
||||
### _instance-var_ `matcher` {#Plugin-matcher}
|
||||
|
||||
- **类型:** set[Type[nonebot.internal.matcher.Matcher]]
|
||||
|
||||
- **说明:** 插件内定义的 `Matcher`
|
||||
|
||||
### _instance-var_ `sub_plugins` {#Plugin-sub_plugins}
|
||||
|
||||
- **类型:** set[Plugin]
|
||||
|
||||
- **说明:** 子插件集合
|
||||
|
||||
## _def_ `get_plugin(name)` {#get_plugin}
|
||||
|
||||
- **说明**
|
||||
|
||||
获取已经导入的某个插件。
|
||||
|
||||
如果为 `load_plugins` 文件夹导入的插件,则为文件(夹)名。
|
||||
|
||||
- **参数**
|
||||
|
||||
- `name` (str): 插件名,即 [Plugin.name](#Plugin-name)。
|
||||
|
||||
- **返回**
|
||||
|
||||
- [Plugin](#Plugin) | None
|
||||
|
||||
## _def_ `get_loaded_plugins()` {#get_loaded_plugins}
|
||||
|
||||
- **说明**
|
||||
|
||||
获取当前已导入的所有插件。
|
||||
|
||||
- **返回**
|
||||
|
||||
- set[[Plugin](#Plugin)]
|
Reference in New Issue
Block a user