Skip to main content

监控指定群友发言并调用大模型进行劝阻的 NoneBot2 插件(开关状态 JSON 持久化)

Project description

NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-monitor-study

✨ 劝阻群友水群 / 自动提醒插件 ✨

license python

一个基于 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"]

📦 依赖

  • nonebot2
  • nonebot-adapter-onebot
  • httpx
  • nonebot-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
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_monitor_study-0.1.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_monitor_study-0.1.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_monitor_study-0.1.1.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_monitor_study-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a8a4939f3efb012fc4f75578a10bce5ea63012a58e957408e0d7619f341145fe
MD5 9b4aa1c4c8f62cec522c962ff2a2ae59
BLAKE2b-256 98f08bf086e10a341a286a54a765f44eea8b5f5d29b8e906ee1a9387b9c55ee4

See more details on using hashes here.

File details

Details for the file nonebot_plugin_monitor_study-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_monitor_study-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 76c0b47686396c3f5b5c4aee5fc14a07e0fea7d14336ecb13e38dcc8d2eb11c4
MD5 1c50585034e060e9bfe05944816be2e9
BLAKE2b-256 c79e4e3eab6fcbbc502a04ddfe9e67b22ffb727ce68c39df66db5f0fd36be7fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page