mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-24 09:05:04 +08:00
218 lines
15 KiB
Markdown
218 lines
15 KiB
Markdown
<!-- markdownlint-disable MD033 MD041 -->
|
||
<p align="center">
|
||
<a href="https://v2.nonebot.dev/"><img src="https://v2.nonebot.dev/logo.png" width="200" height="200" alt="nonebot"></a>
|
||
</p>
|
||
|
||
<div align="center">
|
||
|
||
# NoneBot
|
||
|
||
<!-- prettier-ignore-start -->
|
||
<!-- markdownlint-disable-next-line MD036 -->
|
||
_✨ 跨平台 Python 异步机器人框架 ✨_
|
||
<!-- prettier-ignore-end -->
|
||
|
||
</div>
|
||
|
||
<p align="center">
|
||
<a href="https://raw.githubusercontent.com/nonebot/nonebot2/master/LICENSE">
|
||
<img src="https://img.shields.io/github/license/nonebot/nonebot2" alt="license">
|
||
</a>
|
||
<a href="https://pypi.python.org/pypi/nonebot2">
|
||
<img src="https://img.shields.io/pypi/v/nonebot2" alt="pypi">
|
||
</a>
|
||
<img src="https://img.shields.io/badge/python-3.8+-blue" alt="python">
|
||
<a href="https://codecov.io/gh/nonebot/nonebot2">
|
||
<img src="https://codecov.io/gh/nonebot/nonebot2/branch/master/graph/badge.svg?token=2P0G0VS7N4" alt="codecov"/>
|
||
</a>
|
||
<a href="https://github.com/nonebot/nonebot2/actions/workflows/website-deploy.yml">
|
||
<img src="https://github.com/nonebot/nonebot2/actions/workflows/website-deploy.yml/badge.svg?branch=master&event=push" alt="site"/>
|
||
</a>
|
||
<a href="https://results.pre-commit.ci/latest/github/nonebot/nonebot2/master">
|
||
<img src="https://results.pre-commit.ci/badge/github/nonebot/nonebot2/master.svg" alt="pre-commit" />
|
||
</a>
|
||
<br />
|
||
<a href="https://onebot.dev/">
|
||
<img src="https://img.shields.io/badge/OneBot-v11-black?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAAAAADAwMHBwceHh4UFBQNDQ0ZGRkoKCgvLy8iIiLWSdWYAAAAAXRSTlMAQObYZgAAAQVJREFUSMftlM0RgjAQhV+0ATYK6i1Xb+iMd0qgBEqgBEuwBOxU2QDKsjvojQPvkJ/ZL5sXkgWrFirK4MibYUdE3OR2nEpuKz1/q8CdNxNQgthZCXYVLjyoDQftaKuniHHWRnPh2GCUetR2/9HsMAXyUT4/3UHwtQT2AggSCGKeSAsFnxBIOuAggdh3AKTL7pDuCyABcMb0aQP7aM4AnAbc/wHwA5D2wDHTTe56gIIOUA/4YYV2e1sg713PXdZJAuncdZMAGkAukU9OAn40O849+0ornPwT93rphWF0mgAbauUrEOthlX8Zu7P5A6kZyKCJy75hhw1Mgr9RAUvX7A3csGqZegEdniCx30c3agAAAABJRU5ErkJggg==" alt="onebot">
|
||
</a>
|
||
<a href="https://onebot.dev/">
|
||
<img src="https://img.shields.io/badge/OneBot-v12-black?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAAAAADAwMHBwceHh4UFBQNDQ0ZGRkoKCgvLy8iIiLWSdWYAAAAAXRSTlMAQObYZgAAAQVJREFUSMftlM0RgjAQhV+0ATYK6i1Xb+iMd0qgBEqgBEuwBOxU2QDKsjvojQPvkJ/ZL5sXkgWrFirK4MibYUdE3OR2nEpuKz1/q8CdNxNQgthZCXYVLjyoDQftaKuniHHWRnPh2GCUetR2/9HsMAXyUT4/3UHwtQT2AggSCGKeSAsFnxBIOuAggdh3AKTL7pDuCyABcMb0aQP7aM4AnAbc/wHwA5D2wDHTTe56gIIOUA/4YYV2e1sg713PXdZJAuncdZMAGkAukU9OAn40O849+0ornPwT93rphWF0mgAbauUrEOthlX8Zu7P5A6kZyKCJy75hhw1Mgr9RAUvX7A3csGqZegEdniCx30c3agAAAABJRU5ErkJggg==" alt="onebot">
|
||
</a>
|
||
<a href="https://core.telegram.org/bots/api">
|
||
<img src="https://img.shields.io/badge/telegram-Bot-lightgrey?style=social&logo=telegram" alt="telegram">
|
||
</a>
|
||
<a href="https://open.feishu.cn/document/home/index">
|
||
<img src="https://img.shields.io/badge/%E9%A3%9E%E4%B9%A6-Bot-lightgrey?style=social&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xNyAyOUMyMSAyOSAyNSAyNi45MzM5IDI4IDIzLjQwNjVDMzYgMTQgNDEuNDI0MiAxNi44MTY2IDQ0IDE3Ljk5OThDMzguNSAyMC45OTk4IDQwLjUgMjkuNjIzMyAzMyAzNS45OTk4QzI4LjM4MiAzOS45MjU5IDIzLjQ5NDUgNDEuMDE0IDE5IDQxQzEyLjUyMzEgNDAuOTc5OSA2Ljg2MjI2IDM3Ljc2MzcgNCAzNS40MDYzVjE2Ljk5OTgiIHN0cm9rZT0iIzMzMyIgc3Ryb2tlLXdpZHRoPSI0IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48cGF0aCBkPSJNNS42NDgwOCAxNS44NjY5QzUuMDIyMzEgMTQuOTU2NyAzLjc3NzE1IDE0LjcyNjEgMi44NjY5NCAxNS4zNTE5QzEuOTU2NzMgMTUuOTc3NyAxLjcyNjE1IDE3LjIyMjggMi4zNTE5MiAxOC4xMzMxTDUuNjQ4MDggMTUuODY2OVpNMzYuMDAyMSAzNS43MzA5QzM2Ljk1OCAzNS4xNzc0IDM3LjI4NDMgMzMuOTUzOSAzNi43MzA5IDMyLjk5NzlDMzYuMTc3NCAzMi4wNDIgMzQuOTUzOSAzMS43MTU3IDMzLjk5NzkgMzIuMjY5MUwzNi4wMDIxIDM1LjczMDlaTTIuMzUxOTIgMTguMTMzMUM1LjI0MzUgMjIuMzM5IDEwLjc5OTIgMjguMTQ0IDE2Ljg4NjUgMzIuMjIzOUMxOS45MzQ1IDM0LjI2NjcgMjMuMjE3IDM1Ljk0NiAyNi40NDkgMzYuNzMyNEMyOS42OTQ2IDM3LjUyMiAzMy4wNDUxIDM3LjQ0MjggMzYuMDAyMSAzNS43MzA5TDMzLjk5NzkgMzIuMjY5MUMzMi4yMDQ5IDMzLjMwNzIgMjkuOTkyOSAzMy40NzggMjcuMzk0NyAzMi44NDU4QzI0Ljc4MyAzMi4yMTAzIDIxLjk0MDUgMzAuNzk1OCAxOS4xMTM1IDI4LjkwMTFDMTMuNDUwOCAyNS4xMDYgOC4yNTY1IDE5LjY2MSA1LjY0ODA4IDE1Ljg2NjlMMi4zNTE5MiAxOC4xMzMxWiIgZmlsbD0iIzMzMyIvPjxwYXRoIGQ9Ik0zMy41OTQ1IDE3QzMyLjgzOTggMTQuNzAyNyAzMC44NTQ5IDkuOTQwNTQgMjcuNTk0NSA3SDExLjU5NDVDMTUuMjE3MSAxMC42NzU3IDIzIDE2IDI3IDI0IiBzdHJva2U9IiMzMzMiIHN0cm9rZS13aWR0aD0iNCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+" alt="feishu">
|
||
</a>
|
||
<a href="https://docs.github.com/en/developers/apps">
|
||
<img src="https://img.shields.io/badge/GitHub-Bot-181717?style=social&logo=github" alt="github"/>
|
||
</a>
|
||
<a href="https://bot.q.qq.com/wiki/">
|
||
<img src="https://img.shields.io/badge/QQ%E9%A2%91%E9%81%93-Bot-lightgrey?style=social&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMTIuODIgMTMwLjg5Ij48ZyBkYXRhLW5hbWU9IuWbvuWxgiAyIj48ZyBkYXRhLW5hbWU9IuWbvuWxgiAxIj48cGF0aCBkPSJNNTUuNjMgMTMwLjhj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zLjkxIDEuNzUgOS42NC01Ljg4IDEwLTcuNDcuMzctNi44MS00LjgyLTYuNjEtOS41LjItNC4zMi0xLjgzLTEwIDUuNzgtMTAuNDJzNi41OSA0Ljg5IDYuNzEgOS45MnoiIGZpbGw9IiMwODljZmUiLz48L2c+PC9nPjwvc3ZnPg==" alt="QQ频道">
|
||
</a>
|
||
<!-- <a href="https://ding-doc.dingtalk.com/document#/org-dev-guide/elzz1p">
|
||
<img src="https://img.shields.io/badge/%E9%92%89%E9%92%89-Bot-lightgrey?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAnFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4jUzeAAAAM3RSTlMAQKSRaA+/f0YyFevh29R3cyklIfrlyrGsn41tVUs48c/HqJm9uZdhX1otGwkF9IN8V1CX0Q+IAAABY0lEQVRYw+3V2W7CMBAF0JuNQAhhX9OEfYdu9///rUVWpagE27Ef2gfO+0zGozsKnv6bMGzAhkNytIe5gDdzrwtTCwrbI8x4/NF668NAxgI3Q3UtFi3TyPwNQtPLUUmDd8YfqGLNe4v22XwEYb5zoOuF5baHq2UHtsKe5ivWfGAwrWu2mC34QM0PoCAuqZdOmiwV+5BLyMRtZ7dTSEcs48rzWfzwptMLyzpApka1SJ5FtR4kfCqNIBPEVDmqoqgwUYY5plQOlf6UEjNoOPnuKB6wzDyCrks///TDza8+PnR109WQdxLo8RKWq0PPnuXG0OXKQ6wWLFnCg75uYYbhmMIVVdQ709q33aHbGIj6Duz+2k1HQFX9VwqmY8xYsEJll2ahvhWgsjYLHFRXvIi2Qb0jzMQCzC3FAoydxCma88UCzE3JCWwkjCNYyMUCzHX4DiuTMawEwwhW6hnshPhjZzzJfAH0YacpbmRd7QAAAABJRU5ErkJggg==" alt="dingtalk"> -->
|
||
</a>
|
||
<br />
|
||
<a href="https://jq.qq.com/?_wv=1027&k=5OFifDh">
|
||
<img src="https://img.shields.io/badge/QQ%E7%BE%A4-768887710-orange?style=flat-square" alt="QQ Chat Group">
|
||
</a>
|
||
<a href="https://qun.qq.com/qqweb/qunpro/share?_wv=3&_wwv=128&appChannel=share&inviteCode=7b4a3&appChannel=share&businessType=9&from=246610&biz=ka">
|
||
<img src="https://img.shields.io/badge/QQ%E9%A2%91%E9%81%93-NoneBot-5492ff?style=flat-square" alt="QQ Channel">
|
||
</a>
|
||
<a href="https://t.me/botuniverse">
|
||
<img src="https://img.shields.io/badge/telegram-botuniverse-blue?style=flat-square" alt="Telegram Channel">
|
||
</a>
|
||
<a href="https://discord.gg/VKtE6Gdc4h">
|
||
<img src="https://discordapp.com/api/guilds/847819937858584596/widget.png?style=shield" alt="Discord Server">
|
||
</a>
|
||
</p>
|
||
|
||
<p align="center">
|
||
<a href="https://v2.nonebot.dev/">文档</a>
|
||
·
|
||
<a href="https://v2.nonebot.dev/docs/quick-start">快速上手</a>
|
||
·
|
||
<a href="#插件">文档打不开?</a>
|
||
</p>
|
||
|
||
<p align="center">
|
||
<a href="https://asciinema.org/a/569440">
|
||
<img src="https://v2.nonebot.dev/img/setup.svg">
|
||
</a>
|
||
</p>
|
||
|
||
## 简介
|
||
|
||
NoneBot2 是一个现代、跨平台、可扩展的 Python 聊天机器人框架,它基于 Python 的类型注解和异步特性,能够为你的需求实现提供便捷灵活的支持。
|
||
|
||
## 特色
|
||
|
||
- 异步优先:基于 Python 的异步特性,即使是~~非常~~大量的消息,也能吞吐自如
|
||
- 易于开发:配合 NB-CLI 脚手架,代码编写上手简单,没有过多的冗余代码,可以让开发者专注于业务逻辑
|
||
- 生而可靠:100% 类型注解覆盖,配合编辑器的类型推导功能,能将绝大多数的 Bug 杜绝在编辑器中 ([编辑器支持](https://v2.nonebot.dev/docs/editor-support))
|
||
- 社区丰富:社区用户众多,直接和间接用户超过十万人,每天都有大量的活跃用户 ([社区资源](#社区资源))
|
||
- 海纳百川:一个框架,支持多个聊天软件平台,可自定义通信协议
|
||
|
||
| 协议名称 | 状态 | 注释 |
|
||
| :-------------------------------------------------------------------------: | :--: | :----------------------------------------------------------------: |
|
||
| [OneBot 协议](https://onebot.dev/) | ✅ | 支持 QQ、TG、微信公众号等[平台](https://onebot.dev/ecosystem.html) |
|
||
| [Telegram](https://core.telegram.org/bots/api) | ✅ | |
|
||
| [飞书](https://open.feishu.cn/document/home/index) | ✅ | |
|
||
| [GitHub](https://docs.github.com/en/developers/apps) | ✅ | GitHub APP & OAuth APP |
|
||
| [QQ 频道](https://bot.q.qq.com/wiki/) | ✅ | 官方接口调整较多 |
|
||
| [钉钉](https://open.dingtalk.com/document/) | 🤗 | 寻找 Maintainer (暂不可用) |
|
||
| Console | ✅ | 控制台交互 |
|
||
| [开黑啦](https://developer.kookapp.cn/) | ↗️ | 由社区贡献 |
|
||
| [Mirai](https://docs.mirai.mamoe.net/mirai-api-http/) | ↗️ | 由社区贡献 |
|
||
| [Ntchat](https://github.com/JustUndertaker/adapter-ntchat) | ↗️ | 由社区贡献 |
|
||
| [MineCraft (Spigot)](https://github.com/17TheWord/nonebot-adapter-spigot) | ↗️ | 由社区贡献 |
|
||
| [BiliBili Live](https://github.com/wwweww/adapter-bilibili) | ↗️ | 由社区贡献 |
|
||
| [Walle-Q (QQ 协议)](https://github.com/onebot-walle/nonebot_adapter_walleq) | ↗️ | 由社区贡献 |
|
||
|
||
- 坚实后盾:支持多种 web 框架,可自定义替换、组合
|
||
|
||
| 驱动框架 | 类型 |
|
||
| :--------------------------------------------------------: | :----: |
|
||
| [FastAPI](https://fastapi.tiangolo.com/) | 服务端 |
|
||
| [Quart](https://pgjones.gitlab.io/quart/) (异步 Flask) | 服务端 |
|
||
| [aiohttp](https://docs.aiohttp.org/en/stable/) | 客户端 |
|
||
| [httpx](https://www.python-httpx.org/) | 客户端 |
|
||
| [websockets](https://websockets.readthedocs.io/en/stable/) | 客户端 |
|
||
|
||
更多:[概览](https://v2.nonebot.dev/docs/)
|
||
|
||
## 什么不是 NoneBot2
|
||
|
||
NoneBot2 不是某个平台或者协议的具体实现,它只负责和已有协议适配器通信,并处理接收到的事件。所以,“NoneBot 有 blabla 平台的 blabla 功能吗?”这种问题是与 NoneBot2 无关的。请在相应平台的功能文档中确认,或与相应平台的协议适配开发者联系。
|
||
|
||
NoneBot2 不是 NoneBot1 的替代品。事实上,它们都在被积极的维护着。但是,如果你想尝试一些新功能,或者想要支持更多的平台,可以考虑使用 NoneBot2。
|
||
|
||
> ~~NoneBot2 和 NoneBot1 的区别,就像是 VisualStudio Code 和 VisualStudio 一样~~
|
||
|
||
## 即刻开始
|
||
|
||
~~完整~~文档可以在 [这里](https://v2.nonebot.dev/) 查看。
|
||
|
||
懒得看文档?下面是快速安装指南:
|
||
|
||
1. 安装 [pipx](https://pypa.github.io/pipx/)
|
||
|
||
```bash
|
||
python -m pip install --user pipx
|
||
python -m pipx ensurepath
|
||
```
|
||
|
||
2. 安装脚手架
|
||
|
||
```bash
|
||
pipx install nb-cli
|
||
```
|
||
|
||
3. 使用脚手架创建项目
|
||
|
||
```bash
|
||
nb create
|
||
```
|
||
|
||
4. 运行项目
|
||
|
||
```bash
|
||
nb run
|
||
```
|
||
|
||
## 社区资源
|
||
|
||
### 常见问题
|
||
|
||
- [常见问题解答(FAQ)](https://faq.nonebot.dev/)
|
||
- [论坛(Discussion)](https://discussions.nonebot.dev/)
|
||
|
||
### 教程/实际项目/经验分享
|
||
|
||
- [awesome-nonebot](https://github.com/nonebot/awesome-nonebot)
|
||
|
||
### 插件
|
||
|
||
此外,NoneBot2 还有丰富的官方以及第三方现成的插件供大家使用:
|
||
|
||
- [NoneBot-Plugin-Docs](https://github.com/nonebot/nonebot2/tree/master/packages/nonebot-plugin-docs):离线文档至本地项目使用 (别再说文档打不开了!)
|
||
|
||
在项目目录下执行:
|
||
|
||
```bash
|
||
nb plugin install nonebot_plugin_docs
|
||
```
|
||
|
||
或者尝试以下镜像:
|
||
|
||
- [文档镜像(中国境内)](https://nb2.baka.icu)
|
||
- [文档镜像(Vercel)](https://nonebot2-vercel-mirror.vercel.app)
|
||
|
||
- 其他插件请查看 [商店](https://v2.nonebot.dev/store)
|
||
|
||
## 许可证
|
||
|
||
`NoneBot` 采用 `MIT` 许可证进行开源
|
||
|
||
```text
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
```
|
||
|
||
## 贡献
|
||
|
||
请参考 [贡献指南](./CONTRIBUTING.md)
|
||
|
||
### 鸣谢
|
||
|
||
感谢以下开发者对 NoneBot2 作出的贡献:
|
||
|
||
<a href="https://github.com/nonebot/nonebot2/graphs/contributors">
|
||
<img src="https://contrib.rocks/image?repo=nonebot/nonebot2&max=1000" />
|
||
</a>
|