noneflow[bot] 033c90dd74
Some checks failed
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.10) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.11) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.12) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.9) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.10) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.11) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.12) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.9) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.10) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.11) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.11) (push) Failing after 2s
Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.12) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.9) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.10) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.11) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.12) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.9) (push) Waiting to run
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.12) (push) Failing after 6m59s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.10) (push) Failing after 7m7s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.10) (push) Failing after 5m14s
Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.9) (push) Failing after 5m42s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.11) (push) Failing after 4m51s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.12) (push) Failing after 7m12s
Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.9) (push) Failing after 6m33s
Pyright Lint / Pyright Lint (pydantic-v1) (push) Failing after 8m12s
Ruff Lint / Ruff Lint (push) Successful in 43s
Pyright Lint / Pyright Lint (pydantic-v2) (push) Failing after 6m56s
Site Deploy / publish (push) Failing after 7m21s
🔖 Release 2.4.1
2024-12-25 07:21:05 +00:00
..
2024-12-25 07:21:05 +00:00
2024-12-25 07:21:05 +00:00
2024-12-25 07:21:05 +00:00
2024-12-25 07:21:05 +00:00
2024-12-25 07:21:05 +00:00
2024-12-25 07:21:05 +00:00
2024-12-25 07:21:05 +00:00
2024-12-25 07:21:05 +00:00
2024-12-25 07:21:05 +00:00
2024-12-25 07:21:05 +00:00
2024-12-25 07:21:05 +00:00

sidebar_position id slug
0 index /

概览

NoneBot2 是一个现代、跨平台、可扩展的 Python 聊天机器人框架(下称 NoneBot它基于 Python 的类型注解和异步优先特性兼容同步能够为你的需求实现提供便捷灵活的支持。同时NoneBot 拥有大量的开发者为其开发插件,用户无需编写任何代码,仅需完成环境配置及插件安装,就可以正常使用 NoneBot。

需要注意的是NoneBot 仅支持 Python 3.9 以上版本

特色

异步优先

NoneBot 基于 Python asyncio / trio 编写,并在异步机制的基础上进行了一定程度的同步函数兼容。

完整的类型注解

NoneBot 参考 PEP 484 等 PEP 完整实现了类型注解,通过 PyrightPylance 检查。配合编辑器的类型推导功能,能将绝大多数的 Bug 杜绝在编辑器中(编辑器支持)。

开箱即用

NoneBot 提供了使用便捷、具有交互式功能的命令行工具--nb-cli,使得用户初次接触 NoneBot 时更容易上手。使用方法请阅读本文档指南以及 CLI 文档

插件系统

插件系统是 NoneBot 的核心,通过它可以实现机器人的模块化以及功能扩展,便于维护和管理。

依赖注入系统

NoneBot 采用了一套自行定义的依赖注入系统,可以让事件的处理过程更加的简洁、清晰,增加代码的可读性,减少代码冗余。

什么是依赖注入

『依赖注入』意思是,在编程中,有一种方法可以让你的代码声明它工作和使用所需要的东西,即**『依赖』**。

系统(在这里是指 NoneBot将负责做任何需要的事情为你的代码提供这些必要依赖即**『注入』**依赖性)

这在你有以下情形的需求时非常有用:

  • 这部分代码拥有共享的逻辑(同样的代码逻辑多次重复)
  • 共享数据库以及网络请求连接会话
    • 比如 httpx.AsyncClientaiohttp.ClientSessionsqlalchemy.Session
  • 机器人用户权限检查以及认证
  • 还有更多...

它在完成上述工作的同时,还能尽量减少代码的耦合和重复