2021-12-01 16:28:55 +08:00
|
|
|
|
---
|
|
|
|
|
sidebar_position: 2
|
|
|
|
|
|
|
|
|
|
options:
|
|
|
|
|
menu:
|
|
|
|
|
weight: 20
|
2021-12-02 03:17:10 +08:00
|
|
|
|
category: guide
|
2021-12-01 16:28:55 +08:00
|
|
|
|
---
|
|
|
|
|
|
2020-09-12 13:45:03 +08:00
|
|
|
|
# 安装
|
|
|
|
|
|
2021-03-07 17:55:29 +08:00
|
|
|
|
## 安装 NoneBot
|
2020-09-12 13:45:03 +08:00
|
|
|
|
|
|
|
|
|
:::warning 注意
|
|
|
|
|
请确保你的 Python 版本 >= 3.7。
|
|
|
|
|
:::
|
|
|
|
|
|
2020-12-01 12:24:14 +08:00
|
|
|
|
:::warning 注意
|
2021-02-02 19:34:03 +08:00
|
|
|
|
请在安装 NoneBot v2 之前卸载 NoneBot v1
|
2020-10-16 17:15:40 +08:00
|
|
|
|
|
2020-09-12 13:45:03 +08:00
|
|
|
|
```bash
|
2020-10-16 17:15:40 +08:00
|
|
|
|
pip uninstall nonebot
|
2020-12-01 12:24:14 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
|
2021-02-02 19:34:03 +08:00
|
|
|
|
### (推荐安装方式)通过脚手架安装
|
2020-12-01 12:24:14 +08:00
|
|
|
|
|
2021-02-02 19:34:03 +08:00
|
|
|
|
1. (推荐)使用你喜欢的 Python 环境管理工具(如 `poetry`)创建新的虚拟环境
|
|
|
|
|
2. 使用 `pip` 或 其他包管理工具 安装 `nb-cli`,`nonebot2` 会作为其依赖被一起安装
|
2020-12-01 12:24:14 +08:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
pip install nb-cli
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-01 17:08:15 +08:00
|
|
|
|
3. 点个 star 吧
|
|
|
|
|
|
2021-02-02 19:34:03 +08:00
|
|
|
|
nonebot2: [![nonebot2](https://img.shields.io/github/stars/nonebot/nonebot2?style=social)](https://github.com/nonebot/nonebot2)
|
2020-12-01 17:08:15 +08:00
|
|
|
|
|
|
|
|
|
nb-cli: [![nb-cli](https://img.shields.io/github/stars/nonebot/nb-cli?style=social)](https://github.com/nonebot/nb-cli)
|
|
|
|
|
|
2021-02-02 19:34:03 +08:00
|
|
|
|
4. 如果有疑问,可以加群交流(点击链接直达)
|
2021-01-27 12:08:22 +08:00
|
|
|
|
|
|
|
|
|
[![QQ Chat](https://img.shields.io/badge/QQ%E7%BE%A4-768887710-orange?style=social)](https://jq.qq.com/?_wv=1027&k=5OFifDh)
|
|
|
|
|
|
|
|
|
|
[![Telegram Chat](https://img.shields.io/badge/telegram-cqhttp-blue?style=social)](https://t.me/cqhttp)
|
|
|
|
|
|
2021-02-02 19:34:03 +08:00
|
|
|
|
### (纯净安装)不使用脚手架
|
2020-12-01 12:24:14 +08:00
|
|
|
|
|
|
|
|
|
```bash
|
2020-09-12 13:45:03 +08:00
|
|
|
|
pip install nonebot2
|
2020-12-07 21:02:08 +08:00
|
|
|
|
# 也可以通过 poetry 安装
|
|
|
|
|
poetry add nonebot2
|
2020-09-12 13:45:03 +08:00
|
|
|
|
```
|
|
|
|
|
|
2020-12-01 12:24:14 +08:00
|
|
|
|
如果你需要使用最新的(可能**尚未发布**的)特性,可以直接从 GitHub 仓库安装:
|
2020-11-10 14:44:24 +08:00
|
|
|
|
|
2020-12-05 13:06:27 +08:00
|
|
|
|
:::warning 注意
|
2020-12-07 21:02:08 +08:00
|
|
|
|
直接从 Github 仓库中安装意味着你将使用最新提交的代码,它们并没有进行充分的稳定性测试
|
2020-12-05 13:06:27 +08:00
|
|
|
|
在任何情况下请不要将其应用于生产环境!
|
|
|
|
|
:::
|
|
|
|
|
|
2020-11-10 14:44:24 +08:00
|
|
|
|
```bash
|
2020-12-05 13:06:27 +08:00
|
|
|
|
# master分支
|
2020-11-10 14:44:24 +08:00
|
|
|
|
poetry add git+https://github.com/nonebot/nonebot2.git#master
|
2020-12-05 13:06:27 +08:00
|
|
|
|
# dev分支
|
2020-11-10 14:44:24 +08:00
|
|
|
|
poetry add git+https://github.com/nonebot/nonebot2.git#dev
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-05 13:06:27 +08:00
|
|
|
|
或者在克隆 Git 仓库后手动安装:
|
2020-09-12 13:45:03 +08:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
git clone https://github.com/nonebot/nonebot2.git
|
|
|
|
|
cd nonebot2
|
2020-09-17 13:12:48 +08:00
|
|
|
|
poetry install --no-dev # 推荐
|
|
|
|
|
pip install . # 不推荐
|
2020-09-12 13:45:03 +08:00
|
|
|
|
```
|
2020-12-01 18:53:03 +08:00
|
|
|
|
|
2021-03-07 17:55:29 +08:00
|
|
|
|
## 安装适配器
|
2021-03-22 17:27:31 +08:00
|
|
|
|
|
2021-03-07 17:55:29 +08:00
|
|
|
|
适配器可以通过 `nb-cli` 在创建项目时根据你的选择自动安装,也可以自行使用 `pip` 安装
|
|
|
|
|
|
|
|
|
|
```bash
|
2021-04-12 23:34:23 +08:00
|
|
|
|
pip install <adapter-name>
|
2021-03-07 17:55:29 +08:00
|
|
|
|
```
|
|
|
|
|
|
2021-03-07 17:59:25 +08:00
|
|
|
|
```bash
|
|
|
|
|
# 列出所有的适配器
|
|
|
|
|
nb adapter list
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-01 18:53:03 +08:00
|
|
|
|
## 安装插件
|
|
|
|
|
|
|
|
|
|
插件可以通过 `nb-cli` 进行安装,也可以自行安装并加载插件。
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# 列出所有的插件
|
|
|
|
|
nb plugin list
|
|
|
|
|
# 搜索插件
|
2021-04-12 23:34:23 +08:00
|
|
|
|
nb plugin search <plugin-name>
|
2020-12-01 18:53:03 +08:00
|
|
|
|
# 安装插件
|
2021-04-12 23:34:23 +08:00
|
|
|
|
nb plugin install <plugin-name>
|
2020-12-01 18:53:03 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
如果急于上线 Bot 或想要使用现成的插件,以下插件可作为参考:
|
|
|
|
|
|
|
|
|
|
### 官方插件
|
|
|
|
|
|
2020-12-01 19:10:05 +08:00
|
|
|
|
- [NoneBot-Plugin-Docs](https://github.com/nonebot/nonebot2/tree/master/packages/nonebot-plugin-docs) 离线文档插件
|
|
|
|
|
- [NoneBot-Plugin-Test](https://github.com/nonebot/plugin-test) 本地机器人测试前端插件
|
|
|
|
|
- [NoneBot-Plugin-APScheduler](https://github.com/nonebot/plugin-apscheduler) 定时任务插件
|
2021-03-22 17:27:31 +08:00
|
|
|
|
- [NoneBot-Plugin-LocalStore](https://github.com/nonebot/plugin-localstore) 本地数据文件存储插件
|
2020-12-01 19:10:05 +08:00
|
|
|
|
- [NoneBot-Plugin-Sentry](https://github.com/cscs181/QQ-GitHub-Bot/tree/master/src/plugins/nonebot_plugin_sentry) Sentry 在线日志分析插件
|
|
|
|
|
- [NoneBot-Plugin-Status](https://github.com/cscs181/QQ-GitHub-Bot/tree/master/src/plugins/nonebot_plugin_status) 服务器状态查看插件
|
2020-12-01 18:53:03 +08:00
|
|
|
|
|
|
|
|
|
### 其他插件
|
|
|
|
|
|
2021-12-02 03:17:10 +08:00
|
|
|
|
还有更多的插件在 [这里](/store) 等着你发现~
|
2021-04-13 00:24:49 +08:00
|
|
|
|
|
|
|
|
|
## 安装开发环境(可选)
|
|
|
|
|
|
|
|
|
|
NoneBot v2 全程使用 `VSCode` 搭配 `Pylance` 的开发环境进行开发,在严格的类型检查下,NoneBot v2 具有完善的类型设计与声明。
|
|
|
|
|
|
2021-04-16 09:03:00 +08:00
|
|
|
|
在围绕 NoneBot v2 进行开发时,使用 `VSCode` 搭配 `Pylance` 进行类型检查是非常推荐的。这有利于统一代码风格及避免低级错误的发生。
|