mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-28 00:31:14 +00:00
🔖 Release 2.0.0-beta.2
This commit is contained in:
@ -0,0 +1,33 @@
|
||||
---
|
||||
sidebar_position: 80
|
||||
description: 编辑器支持
|
||||
---
|
||||
|
||||
# 编辑器支持
|
||||
|
||||
框架基于 [PEP484](https://www.python.org/dev/peps/pep-0484/)、[PEP 561](https://www.python.org/dev/peps/pep-0517/)、[PEP8](https://www.python.org/dev/peps/pep-0008/) 等规范进行开发并且是 **Fully Typed**。框架使用 `pyright`(`pylance`)工具进行类型检查,确保代码可以被编辑器正确解析。
|
||||
|
||||
## 编辑器推荐配置
|
||||
|
||||
### Visual Studio Code
|
||||
|
||||
在 Visual Studio Code 中,可以使用 `pylance` Language Server 并启用 `Type Checking` 以达到最佳开发体验。
|
||||
|
||||
向 `.vscode` 文件夹中对应文件添加以下配置并在 VSCode 插件面板安装推荐插件:
|
||||
|
||||
```json title=extensions.json
|
||||
{
|
||||
"recommendations": ["ms-python.python", "ms-python.vscode-pylance"]
|
||||
}
|
||||
```
|
||||
|
||||
```json title=settings.json
|
||||
{
|
||||
"python.languageServer": "Pylance",
|
||||
"python.analysis.typeCheckingMode": "basic"
|
||||
}
|
||||
```
|
||||
|
||||
### 其他
|
||||
|
||||
欢迎提交 Pull Request 添加其他编辑器配置推荐。点击左下角 `Edit this page` 前往编辑。
|
@ -0,0 +1,45 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
description: 通过脚手架或 pip 安装适配器
|
||||
---
|
||||
|
||||
import Asciinema from "@site/src/components/Asciinema";
|
||||
|
||||
# 安装协议适配器
|
||||
|
||||
## 查看
|
||||
|
||||
前往[商店](/store)即可查看所有协议适配器。
|
||||
|
||||
或者使用 nb-cli 命令行查看:
|
||||
|
||||
```bash
|
||||
nb adapter list
|
||||
```
|
||||
|
||||
## 安装
|
||||
|
||||
前往[商店](/store)点击复制 nb-cli 安装命令至命令行执行即可安装。
|
||||
|
||||
或者自行输入命令安装:
|
||||
|
||||
```bash
|
||||
nb adapter install <adapter-name>
|
||||
```
|
||||
|
||||
或者使用交互模式安装:
|
||||
|
||||
```bash
|
||||
nb adapter install
|
||||
```
|
||||
|
||||
也可以使用 pip 安装
|
||||
|
||||
```bash
|
||||
pip install <adapter-name>
|
||||
```
|
||||
|
||||
<Asciinema
|
||||
url="https://asciinema.org/a/464727.cast"
|
||||
options={{ theme: "monokai", poster: "npt:2.0" }}
|
||||
/>
|
@ -0,0 +1,47 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
description: 通过脚手架或 pip 安装驱动器
|
||||
---
|
||||
|
||||
import Asciinema from "@site/src/components/Asciinema";
|
||||
|
||||
# 安装驱动器
|
||||
|
||||
NoneBot 在默认安装情况下内置了 `fastapi` 服务端驱动器,其他驱动器如 `httpx`、`aiohttp` 则需要额外安装。
|
||||
|
||||
## 查看
|
||||
|
||||
前往[商店](/store)即可查看所有驱动器。
|
||||
|
||||
或者使用 nb-cli 命令行查看:
|
||||
|
||||
```bash
|
||||
nb driver list
|
||||
```
|
||||
|
||||
## 安装
|
||||
|
||||
前往[商店](/store)点击复制 nb-cli 安装命令至命令行执行即可安装。
|
||||
|
||||
或者自行输入命令安装:
|
||||
|
||||
```bash
|
||||
nb driver install <driver-name>
|
||||
```
|
||||
|
||||
或者使用交互模式安装:
|
||||
|
||||
```bash
|
||||
nb driver install
|
||||
```
|
||||
|
||||
也可以使用 pip 安装
|
||||
|
||||
```bash
|
||||
pip install <driver-name>
|
||||
```
|
||||
|
||||
<Asciinema
|
||||
url="https://asciinema.org/a/464686.cast"
|
||||
options={{ theme: "monokai", poster: "npt:2.8" }}
|
||||
/>
|
@ -0,0 +1,45 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
description: 通过脚手架或 pip 安装插件
|
||||
---
|
||||
|
||||
import Asciinema from "@site/src/components/Asciinema";
|
||||
|
||||
# 安装第三方插件
|
||||
|
||||
## 查看
|
||||
|
||||
前往[商店](/store)即可查看所有发布的插件。
|
||||
|
||||
或者使用 nb-cli 命令行查看:
|
||||
|
||||
```bash
|
||||
nb plugin list
|
||||
```
|
||||
|
||||
## 安装
|
||||
|
||||
前往[商店](/store)点击复制 nb-cli 安装命令至命令行执行即可安装。
|
||||
|
||||
或者自行输入命令安装:
|
||||
|
||||
```bash
|
||||
nb plugin install <plugin-name>
|
||||
```
|
||||
|
||||
或者使用交互模式安装:
|
||||
|
||||
```bash
|
||||
nb plugin install
|
||||
```
|
||||
|
||||
也可以使用 pip 安装
|
||||
|
||||
```bash
|
||||
pip install <plugin-name>
|
||||
```
|
||||
|
||||
<Asciinema
|
||||
url="https://asciinema.org/a/464735.cast"
|
||||
options={{ theme: "monokai", poster: "npt:4.3" }}
|
||||
/>
|
@ -0,0 +1,80 @@
|
||||
---
|
||||
sidebar_position: 0
|
||||
description: 通过脚手架、PyPI 或 GitHub 安装 NoneBot2
|
||||
|
||||
options:
|
||||
menu:
|
||||
weight: 10
|
||||
category: guide
|
||||
---
|
||||
|
||||
import Asciinema from "@site/src/components/Asciinema";
|
||||
|
||||
# 安装 NoneBot2
|
||||
|
||||
:::warning 注意
|
||||
请确保你的 Python 版本 >= 3.7.3。
|
||||
:::
|
||||
|
||||
:::warning 注意
|
||||
请在安装 NoneBot v2 之前卸载 NoneBot v1
|
||||
|
||||
```bash
|
||||
pip uninstall nonebot
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## 通过脚手架安装(推荐)
|
||||
|
||||
1. (可选)使用你喜欢的 Python 环境管理工具(如 Poetry、venv、Conda 等)创建新的虚拟环境
|
||||
2. 使用 pip 或其他包管理工具安装 nb-cli,NoneBot2 会作为其依赖被一起安装
|
||||
|
||||
```bash
|
||||
pip install nb-cli
|
||||
```
|
||||
|
||||
<Asciinema
|
||||
url="https://asciinema.org/a/464654.cast"
|
||||
options={{ theme: "monokai", poster: "npt:2.8" }}
|
||||
/>
|
||||
|
||||
:::important 提示
|
||||
nb-cli 的使用方法详见[使用脚手架](./nb-cli.md)
|
||||
:::
|
||||
|
||||
## 不使用脚手架(纯净安装)
|
||||
|
||||
如果你不想使用脚手架,可以直接安装 NoneBot2,并自行完成开发配置。
|
||||
|
||||
```bash
|
||||
pip install nonebot2
|
||||
# 也可以通过 Poetry 安装
|
||||
poetry add nonebot2
|
||||
```
|
||||
|
||||
## 从 GitHub 安装
|
||||
|
||||
如果你需要使用最新的(可能**尚未发布**的)特性,可以直接从 GitHub 仓库安装:
|
||||
|
||||
:::warning 注意
|
||||
直接从 GitHub 仓库中安装意味着你将使用最新提交的代码,它们并没有进行充分的稳定性测试
|
||||
|
||||
在任何情况下请不要将其应用于生产环境!
|
||||
:::
|
||||
|
||||
```bash title="Install From GitHub"
|
||||
# master分支
|
||||
poetry add git+https://github.com/nonebot/nonebot2.git#master
|
||||
# dev分支
|
||||
poetry add git+https://github.com/nonebot/nonebot2.git#dev
|
||||
```
|
||||
|
||||
或者在克隆 Git 仓库后手动安装:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/nonebot/nonebot2.git
|
||||
cd nonebot2
|
||||
poetry install --no-dev # 推荐
|
||||
pip install . # 不推荐
|
||||
```
|
84
website/versioned_docs/version-2.0.0-beta.2/start/nb-cli.md
Normal file
84
website/versioned_docs/version-2.0.0-beta.2/start/nb-cli.md
Normal file
@ -0,0 +1,84 @@
|
||||
---
|
||||
sidebar_position: 90
|
||||
description: 使用 nb-cli 帮助开发
|
||||
|
||||
options:
|
||||
menu:
|
||||
weight: 11
|
||||
category: guide
|
||||
---
|
||||
|
||||
# 使用脚手架
|
||||
|
||||
## 安装
|
||||
|
||||
```bash
|
||||
pip install nb-cli
|
||||
```
|
||||
|
||||
## 初次使用
|
||||
|
||||
在安装完成之后,即可在命令行使用 nb-cli 的命令 `nb` 进行开发:
|
||||
|
||||
```bash
|
||||
# 直接使用 nb 命令
|
||||
nb
|
||||
# 或使用 Python 执行 module
|
||||
python -m nb_cli
|
||||
```
|
||||
|
||||
:::warning 注意
|
||||
通常情况下,你可以直接在命令行使用 `nb` 命令,但如果命令行出现 `Command not found` 错误,这是由于环境变量 `PATH` 没有正确配置或未配置导致的,可以使用第二种方式代替。
|
||||
:::
|
||||
|
||||
## 使用方式
|
||||
|
||||
nb-cli 具有两种使用方式:
|
||||
|
||||
1. 命令行指令
|
||||
|
||||
查看帮助信息:
|
||||
|
||||
```bash
|
||||
$ nb --help
|
||||
Usage: nb [OPTIONS] COMMAND [ARGS]...
|
||||
|
||||
Options:
|
||||
-V, --version Show the version and exit.
|
||||
--help Show this message and exit.
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
查看子命令帮助:
|
||||
|
||||
```bash
|
||||
$ nb plugin --help
|
||||
Usage: nb plugin [OPTIONS] COMMAND [ARGS]...
|
||||
|
||||
Manage Bot Plugin.
|
||||
|
||||
Options:
|
||||
--help Show this message and exit.
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
2. 交互式选择(支持鼠标)
|
||||
|
||||
交互式选择菜单:
|
||||
|
||||
```bash
|
||||
$ nb
|
||||
Welcome to NoneBot CLI!
|
||||
[?] What do you want to do? (Use ↑ and ↓ to choose, Enter to submit)
|
||||
...
|
||||
```
|
||||
|
||||
交互式子命令菜单:
|
||||
|
||||
```bash
|
||||
$ nb plugin
|
||||
[?] What do you want to do? (Use ↑ and ↓ to choose, Enter to submit)
|
||||
...
|
||||
```
|
@ -0,0 +1,28 @@
|
||||
---
|
||||
sidebar-position: 100
|
||||
description: 如何获取帮助
|
||||
---
|
||||
|
||||
# 遇到问题
|
||||
|
||||
如果在安装或者开发过程中遇到了任何问题,可以通过以下方式解决:
|
||||
|
||||
1. 点击下方链接前往 GitHub,前往 Issues 页面,在 `New Issue` Template 中选择 `Question`
|
||||
|
||||
NoneBot2:[](https://github.com/nonebot/nonebot2)
|
||||
|
||||
2. 通过 QQ 群(点击下方链接直达)
|
||||
|
||||
[](https://jq.qq.com/?_wv=1027&k=5OFifDh)
|
||||
|
||||
3. 通过 QQ 频道
|
||||
|
||||
前往 QQ 频道搜索 NoneBot 点击加入
|
||||
|
||||
4. 通过 Telegram 群(点击下方链接直达)
|
||||
|
||||
[](https://t.me/cqhttp)
|
||||
|
||||
5. 通过 Discord 服务器(点击下方链接直达)
|
||||
|
||||
[](https://discord.gg/VKtE6Gdc4h)
|
Reference in New Issue
Block a user