mirror of
https://github.com/nonebot/nonebot2.git
synced 2026-01-22 11:42:21 +00:00
📝 Docs: 修复插件编写准备文档中的文本错误 (#3746)
Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com>
This commit is contained in:
@@ -48,8 +48,10 @@ options:
|
|||||||
|
|
||||||
```tree title=Project
|
```tree title=Project
|
||||||
📦 awesome-bot
|
📦 awesome-bot
|
||||||
|
├── 📂 .venv
|
||||||
├── 📂 awesome_bot
|
├── 📂 awesome_bot
|
||||||
│ └── 📂 plugins
|
│ └── 📂 plugins
|
||||||
|
├── 📜 .env.prod
|
||||||
├── 📜 pyproject.toml
|
├── 📜 pyproject.toml
|
||||||
└── 📜 README.md
|
└── 📜 README.md
|
||||||
```
|
```
|
||||||
@@ -91,18 +93,20 @@ options:
|
|||||||
$ nb plugin create
|
$ nb plugin create
|
||||||
[?] 插件名称: weather
|
[?] 插件名称: weather
|
||||||
[?] 使用嵌套插件? (y/N) N
|
[?] 使用嵌套插件? (y/N) N
|
||||||
[?] 输出目录: awesome_bot/plugins
|
[?] 请输入插件存储位置: awesome_bot/plugins
|
||||||
```
|
```
|
||||||
|
|
||||||
`nb-cli` 会在 `awesome_bot/plugins` 目录下创建一个名为 `weather` 的文件夹,其中包含的文件将在稍后章节中用到。
|
`nb-cli` 会在 `awesome_bot/plugins` 目录下创建一个名为 `weather` 的文件夹,其中包含的文件将在稍后章节中用到。
|
||||||
|
|
||||||
```tree title=Project
|
```tree title=Project
|
||||||
📦 awesome-bot
|
📦 awesome-bot
|
||||||
|
├── 📂 .venv
|
||||||
├── 📂 awesome_bot
|
├── 📂 awesome_bot
|
||||||
│ └── 📂 plugins
|
│ └── 📂 plugins
|
||||||
| └── 📂 foo
|
| └── 📂 weather
|
||||||
| ├── 📜 __init__.py
|
| ├── 📜 __init__.py
|
||||||
| └── 📜 config.py
|
| └── 📜 config.py
|
||||||
|
├── 📜 .env.prod
|
||||||
├── 📜 pyproject.toml
|
├── 📜 pyproject.toml
|
||||||
└── 📜 README.md
|
└── 📜 README.md
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -48,8 +48,10 @@ options:
|
|||||||
|
|
||||||
```tree title=Project
|
```tree title=Project
|
||||||
📦 awesome-bot
|
📦 awesome-bot
|
||||||
|
├── 📂 .venv
|
||||||
├── 📂 awesome_bot
|
├── 📂 awesome_bot
|
||||||
│ └── 📂 plugins
|
│ └── 📂 plugins
|
||||||
|
├── 📜 .env.prod
|
||||||
├── 📜 pyproject.toml
|
├── 📜 pyproject.toml
|
||||||
└── 📜 README.md
|
└── 📜 README.md
|
||||||
```
|
```
|
||||||
@@ -91,18 +93,20 @@ options:
|
|||||||
$ nb plugin create
|
$ nb plugin create
|
||||||
[?] 插件名称: weather
|
[?] 插件名称: weather
|
||||||
[?] 使用嵌套插件? (y/N) N
|
[?] 使用嵌套插件? (y/N) N
|
||||||
[?] 输出目录: awesome_bot/plugins
|
[?] 请输入插件存储位置: awesome_bot/plugins
|
||||||
```
|
```
|
||||||
|
|
||||||
`nb-cli` 会在 `awesome_bot/plugins` 目录下创建一个名为 `weather` 的文件夹,其中包含的文件将在稍后章节中用到。
|
`nb-cli` 会在 `awesome_bot/plugins` 目录下创建一个名为 `weather` 的文件夹,其中包含的文件将在稍后章节中用到。
|
||||||
|
|
||||||
```tree title=Project
|
```tree title=Project
|
||||||
📦 awesome-bot
|
📦 awesome-bot
|
||||||
|
├── 📂 .venv
|
||||||
├── 📂 awesome_bot
|
├── 📂 awesome_bot
|
||||||
│ └── 📂 plugins
|
│ └── 📂 plugins
|
||||||
| └── 📂 foo
|
| └── 📂 weather
|
||||||
| ├── 📜 __init__.py
|
| ├── 📜 __init__.py
|
||||||
| └── 📜 config.py
|
| └── 📜 config.py
|
||||||
|
├── 📜 .env.prod
|
||||||
├── 📜 pyproject.toml
|
├── 📜 pyproject.toml
|
||||||
└── 📜 README.md
|
└── 📜 README.md
|
||||||
```
|
```
|
||||||
@@ -189,12 +193,16 @@ nonebot.load_from_json("plugin_config.json", encoding="utf-8")
|
|||||||
|
|
||||||
### `load_from_toml`
|
### `load_from_toml`
|
||||||
|
|
||||||
通过 TOML 文件加载插件,是 [`load_all_plugins`](#load_all_plugins) 的 TOML 变种。通过读取 TOML 文件中的 `[tool.nonebot]` Table 中的 `plugins` 和 `plugin_dirs` Array 进行加载。例如:
|
通过 TOML 文件加载插件,是 [`load_all_plugins`](#load_all_plugins) 的 TOML 变种。通过读取 TOML 文件中的 `[tool.nonebot]` Table 中的 `plugin_dirs` Array 与
|
||||||
|
`[tool.nonebot.plugins]` Table 中的多个 Array 进行加载。例如:
|
||||||
|
|
||||||
```toml title=plugin_config.toml
|
```toml title=plugin_config.toml
|
||||||
[tool.nonebot]
|
[tool.nonebot]
|
||||||
plugins = ["path.to.your.plugin"]
|
|
||||||
plugin_dirs = ["path/to/your/plugins"]
|
plugin_dirs = ["path/to/your/plugins"]
|
||||||
|
|
||||||
|
[tool.nonebot.plugins]
|
||||||
|
"@local" = ["path.to.your.plugin"] # 本地插件等非插件商店来源的插件
|
||||||
|
"nonebot-plugin-someplugin" = ["nonebot_plugin_someplugin"] # 插件商店来源的插件
|
||||||
```
|
```
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|||||||
@@ -48,8 +48,10 @@ options:
|
|||||||
|
|
||||||
```tree title=Project
|
```tree title=Project
|
||||||
📦 awesome-bot
|
📦 awesome-bot
|
||||||
|
├── 📂 .venv
|
||||||
├── 📂 awesome_bot
|
├── 📂 awesome_bot
|
||||||
│ └── 📂 plugins
|
│ └── 📂 plugins
|
||||||
|
├── 📜 .env.prod
|
||||||
├── 📜 pyproject.toml
|
├── 📜 pyproject.toml
|
||||||
└── 📜 README.md
|
└── 📜 README.md
|
||||||
```
|
```
|
||||||
@@ -91,18 +93,20 @@ options:
|
|||||||
$ nb plugin create
|
$ nb plugin create
|
||||||
[?] 插件名称: weather
|
[?] 插件名称: weather
|
||||||
[?] 使用嵌套插件? (y/N) N
|
[?] 使用嵌套插件? (y/N) N
|
||||||
[?] 输出目录: awesome_bot/plugins
|
[?] 请输入插件存储位置: awesome_bot/plugins
|
||||||
```
|
```
|
||||||
|
|
||||||
`nb-cli` 会在 `awesome_bot/plugins` 目录下创建一个名为 `weather` 的文件夹,其中包含的文件将在稍后章节中用到。
|
`nb-cli` 会在 `awesome_bot/plugins` 目录下创建一个名为 `weather` 的文件夹,其中包含的文件将在稍后章节中用到。
|
||||||
|
|
||||||
```tree title=Project
|
```tree title=Project
|
||||||
📦 awesome-bot
|
📦 awesome-bot
|
||||||
|
├── 📂 .venv
|
||||||
├── 📂 awesome_bot
|
├── 📂 awesome_bot
|
||||||
│ └── 📂 plugins
|
│ └── 📂 plugins
|
||||||
| └── 📂 foo
|
| └── 📂 weather
|
||||||
| ├── 📜 __init__.py
|
| ├── 📜 __init__.py
|
||||||
| └── 📜 config.py
|
| └── 📜 config.py
|
||||||
|
├── 📜 .env.prod
|
||||||
├── 📜 pyproject.toml
|
├── 📜 pyproject.toml
|
||||||
└── 📜 README.md
|
└── 📜 README.md
|
||||||
```
|
```
|
||||||
@@ -189,12 +193,16 @@ nonebot.load_from_json("plugin_config.json", encoding="utf-8")
|
|||||||
|
|
||||||
### `load_from_toml`
|
### `load_from_toml`
|
||||||
|
|
||||||
通过 TOML 文件加载插件,是 [`load_all_plugins`](#load_all_plugins) 的 TOML 变种。通过读取 TOML 文件中的 `[tool.nonebot]` Table 中的 `plugins` 和 `plugin_dirs` Array 进行加载。例如:
|
通过 TOML 文件加载插件,是 [`load_all_plugins`](#load_all_plugins) 的 TOML 变种。通过读取 TOML 文件中的 `[tool.nonebot]` Table 中的 `plugin_dirs` Array 与
|
||||||
|
`[tool.nonebot.plugins]` Table 中的多个 Array 进行加载。例如:
|
||||||
|
|
||||||
```toml title=plugin_config.toml
|
```toml title=plugin_config.toml
|
||||||
[tool.nonebot]
|
[tool.nonebot]
|
||||||
plugins = ["path.to.your.plugin"]
|
|
||||||
plugin_dirs = ["path/to/your/plugins"]
|
plugin_dirs = ["path/to/your/plugins"]
|
||||||
|
|
||||||
|
[tool.nonebot.plugins]
|
||||||
|
"@local" = ["path.to.your.plugin"] # 本地插件等非插件商店来源的插件
|
||||||
|
"nonebot-plugin-someplugin" = ["nonebot_plugin_someplugin"] # 插件商店来源的插件
|
||||||
```
|
```
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|||||||
@@ -48,8 +48,10 @@ options:
|
|||||||
|
|
||||||
```tree title=Project
|
```tree title=Project
|
||||||
📦 awesome-bot
|
📦 awesome-bot
|
||||||
|
├── 📂 .venv
|
||||||
├── 📂 awesome_bot
|
├── 📂 awesome_bot
|
||||||
│ └── 📂 plugins
|
│ └── 📂 plugins
|
||||||
|
├── 📜 .env.prod
|
||||||
├── 📜 pyproject.toml
|
├── 📜 pyproject.toml
|
||||||
└── 📜 README.md
|
└── 📜 README.md
|
||||||
```
|
```
|
||||||
@@ -91,18 +93,20 @@ options:
|
|||||||
$ nb plugin create
|
$ nb plugin create
|
||||||
[?] 插件名称: weather
|
[?] 插件名称: weather
|
||||||
[?] 使用嵌套插件? (y/N) N
|
[?] 使用嵌套插件? (y/N) N
|
||||||
[?] 输出目录: awesome_bot/plugins
|
[?] 请输入插件存储位置: awesome_bot/plugins
|
||||||
```
|
```
|
||||||
|
|
||||||
`nb-cli` 会在 `awesome_bot/plugins` 目录下创建一个名为 `weather` 的文件夹,其中包含的文件将在稍后章节中用到。
|
`nb-cli` 会在 `awesome_bot/plugins` 目录下创建一个名为 `weather` 的文件夹,其中包含的文件将在稍后章节中用到。
|
||||||
|
|
||||||
```tree title=Project
|
```tree title=Project
|
||||||
📦 awesome-bot
|
📦 awesome-bot
|
||||||
|
├── 📂 .venv
|
||||||
├── 📂 awesome_bot
|
├── 📂 awesome_bot
|
||||||
│ └── 📂 plugins
|
│ └── 📂 plugins
|
||||||
| └── 📂 foo
|
| └── 📂 weather
|
||||||
| ├── 📜 __init__.py
|
| ├── 📜 __init__.py
|
||||||
| └── 📜 config.py
|
| └── 📜 config.py
|
||||||
|
├── 📜 .env.prod
|
||||||
├── 📜 pyproject.toml
|
├── 📜 pyproject.toml
|
||||||
└── 📜 README.md
|
└── 📜 README.md
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user