Add HeXi bot codebase: custom plugins, web frontends, tests

- hexi core: message handling, rate limiting, cooldown, plugin manager
- Custom plugins: BF stats, daily check-in, quotes, persona cards, etc.
- Community plugins vendored under hexi/plugins with local fixes
- Web admin frontends (learning-chat, persona-admin), unified hexi/web
- Tests for rate_limit/cooldown/memes/persona; poetry.lock

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-09-01 13:13:40 +08:00
co-authored by Claude
parent 1783c60afa
commit b61d09f09f
3201 changed files with 160436 additions and 171 deletions
@@ -0,0 +1,60 @@
# nonebot_plugin_group_daily_analysis(OneBot V11 最小可用版)
移植自 astrbot_plugin_qq_group_daily_analysis(GitHub: SXP-Simon/astrbot_plugin_qq_group_daily_analysis),
保留其领域分析 / 报告生成 / 持久化核心,把 AstrBot 全平台外壳重写为 NoneBot2 + OneBot V11。
## 群内指令(均需 @ 机器人,且群管理员 / 群主 / 超管)
- 群分析 [天数] :手动触发分析,可选最近 N 天(默认用配置里的时间窗口)
- 查看模板 :列出可用报告模板及其编号,标出当前模板
- 设置模板 [序号/名称] :切换报告模板,支持 1..9 编号或模板名
- 分析设置 :查看当前分析参数(时间窗口 / 消息数 / 输出格式 / 模板 / 功能开关)
- 设置分析 [参数] [值] :修改分析参数,见下表
设置分析 支持的参数:
天数/窗口 [N] 时间窗口,最近 N 天
最大消息 [N] 单次最多拉取消息数
最小消息 [N] 自动分析的最小消息阈值
输出格式 [image/text]
话题 / 称号 / 金句 / 聊天质量 [开/关]
## 已有能力
- 群分析:Onbot V11 get_group_msg_history 分页拉取近 N 天群聊
- 话题分析 / 用户形象 / 群聊金句 / 聊天质量(OpenAI 兼容 LLM)
- Playwright 渲染报告 HTML 为图片;报告内容以合并转发 (send_forward_msg) 发送,失败时回退直接发送
- 历史摘要、本地 KV、断点检查点落盘到数据目录
## 尚未接入(后续阶段)
- 定时自动分析、增量分析、群漫画、多平台(Telegram/Discord/QQ 官方)
- AstrBot 版 WebUI 看板
- 群白名单管理指令
## 安装 / 启用
1. 插件目录已在 hexi/plugins/nonebot_plugin_group_daily_analysis,随 hexi/plugins 自动加载。
2. 依赖:pip install ulid-py diskcache(已在 requirements.txt 追加)。
3. 配置 LLM(环境变量,写入 NoneBot 的 .env):
HEXI_LLM_API_BASE=https://api.openai.com/v1
HEXI_LLM_API_KEY=sk-xxx
HEXI_LLM_MODEL=gpt-4o-mini
支持任何 OpenAI 兼容端点(One API / 中转 / 本地 vLLM 等)。
## 配置
配置文件:hexi/data/group_daily_analysis/config.json(首次运行由 _conf_schema.json 生成默认值)。
命令里的 设置分析 / 设置模板 会直接写回该文件,改完即生效。
重点键:
- basic.analysis_days:时间窗口(最近 N 天)
- basic.max_messages:单次最大拉取消息数
- basic.output_format:["image"] 或 ["text"]
- basic.report_template:当前模板名(如 ATRI / scrapbook / BlueArchive)
- analysis_features.topic_analysis_enabled / user_title_analysis_enabled / golden_quote_analysis_enabled / chat_quality_analysis_enabled
- llm.llm_retries / llm.llm_backoff
注意:HEXI_LLM_API_BASE/KEY/MODEL 来自 .env 且优先于 config.json,不会被配置文件覆盖。