一个基于 NoneBot2 + OneBot v11 的群聊监控插件:当指定 QQ 在群里发言时,自动调用 OneAPI / OpenAI 兼容接口生成回复进行“劝阻”。
插件开关状态会写入本地 JSON 状态文件,重启后依然生效;其余配置从 .env 读取。
📖 介绍
nonebot-plugin-monitor-study 用于在群聊中监控指定 QQ 号的发言:
- 仅当消息发送者在
MONITOR_QQ_NUMBERS配置名单里时触发 - 自动调用大模型接口生成回复
- 支持指令 开启/关闭(仅影响插件开关),开关状态会持久化到 JSON 文件
当前实现:每次触发只回复 1 次(你的代码中已改为单次回复)。
💿 安装
使用 nb-cli 安装
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装(包名以你实际发布为准)
nb plugin install nonebot_plugin_monitor_study
使用包管理器安装
pip
pip install nonebot-plugin-monitor-study
然后在 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加:
plugins = ["nonebot_plugin_monitor_study"]
📦 依赖
nonebot2nonebot-adapter-onebothttpxnonebot-plugin-localstore(用于保存 JSON 状态文件)
安装 localstore:
pip install nonebot-plugin-localstore
⚙️ 配置
在 nonebot2 项目的 .env 文件中添加配置(变量名可按你项目实际映射调整)。
| 配置项 | 必填 | 默认值 | 说明 |
|---|---|---|---|
MONITOR_STATUS |
否 | true |
默认监控开关(仅首次运行/无状态文件时使用) |
MONITOR_QQ_NUMBERS |
是 | [] |
需要监控的 QQ 列表(示例:[123,456]) |
PROMPT |
否 | "" |
system prompt |
ONE_API_URL |
是 | "" |
OneAPI/OpenAI 兼容接口地址(示例:https://xxx/v1) |
ONE_API_TOKEN |
是 | "" |
接口 Token |
ONE_API_MODEL |
是 | "" |
模型名(如 gpt-4o-mini / qwen2.5 等,以你的 OneAPI 配置为准) |
关于状态持久化(JSON)
插件只会把 开关状态 写入本地文件:
- 文件名:
monitor_study_state.json - 位置:由
nonebot_plugin_localstore管理(通常在 bot 的数据目录下)
JSON 内容示例:
{
"monitor_status": true
}
Metadata
Release files for nonebot-plugin-monitor-study 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nonebot_plugin_monitor_study-0.2.4.tar.gz | 7.7 kB | Without provenance | Details for nonebot_plugin_monitor_study-0.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonebot_plugin_monitor_study-0.2.4-py3-none-any.whl | Python 3 | none | any | Details for nonebot_plugin_monitor_study-0.2.4-py3-none-any.whl |
Total release size: 16.9 kB
Release files / nonebot_plugin_monitor_study-0.2.4.tar.gz
| Download URL | nonebot_plugin_monitor_study-0.2.4.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4dc61cbc0d3f7ee43f5ba3b03384766a7011e25249ee07a064d2594fede070fe
|
|
BLAKE2b-256 checksum How to use checksums |
2393b6658f4d31658ff391c25360fc5be15b62c0193973b05f030a41076f8ecf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.14.2 Darwin/25.2.0
|
Release files / nonebot_plugin_monitor_study-0.2.4-py3-none-any.whl
| Download URL | nonebot_plugin_monitor_study-0.2.4-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32d8bf7c2e0dee42f9f6d0e060330c56848c44f72048e5420e848544ad368bbe
|
|
BLAKE2b-256 checksum How to use checksums |
c92a8c3a9a42704dc1d11a2dd1871fa9bd1e2ec8482cc147b96d7a366a9a83c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.14.2 Darwin/25.2.0
|
Security for nonebot-plugin-monitor-study 0.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.