Metadata-Version: 2.4
Name: nonebot-plugin-group-heat
Version: 0.2.0
Summary: 群热度统计插件 - 实时查询群内热度，生成昨日热度折线图
Author-email: Wojusensei <3442006415@qq.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/Wojusensei/nonebot-plugin-group-heat
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: nonebot2>=2.3.0
Requires-Dist: nonebot-adapter-onebot>=2.0.0
Requires-Dist: nonebot-plugin-localstore>=0.5.0
Requires-Dist: nonebot-plugin-apscheduler>=0.3.0
Requires-Dist: matplotlib>=3.5.0
Provides-Extra: test
Requires-Dist: pytest<9,>=8.0; extra == "test"
Requires-Dist: pytest-asyncio; extra == "test"
Requires-Dist: nonebug>=0.4.0; extra == "test"

# nonebot-plugin-group-heat

群热度统计插件 for NoneBot2

## 功能

- `/群热度` - 获取过去30分钟的群热度值，附带 bot 评价
- `/昨日热度图` - 生成昨日每30分钟的热度折线图，并显示平均热度

## 热度计算规则

| 消息类型 | 热度值 |
|---------|--------|
| 文本消息 | +0.05 |
| 表情包 | +0.20 |
| 文件（图片/视频/语音等） | +0.30 |
| 其他消息 | 不计入 |

- 每个统计周期的初始热度为 -10°

## 评价机制

| 热度范围 | 评价 |
|---------|------|
| < 0 | 群成冰块啦，群主快开暖气 |
| 0 ~ 10 | 是冬天到了吗，好冷www |
| 10 ~ 20 | 温度非常舒适，大家继续努力~ |
| 20 ~ 30 | 群热度达到最佳状态！ |
| 30 ~ 39 | 好热，群主快开空调！ |
| ≥ 39 | 请发送高温补贴喵。。 |

## 安装

```bash
nb plugin install nonebot-plugin-group-heat
pip install nonebot-plugin-group-heat
```

## 使用
在群聊中发送以下命令：

/群热度 - 查询过去30分钟的群热度

/昨日热度图 - 获取昨日热度折线图

## 配置
默认即装即用，可选配置项（写入 .env 文件）：

```ini
group_heat_retention_days=7
```

消息记录保留天数，超过保留期的记录每天自动清理，防止数据库无限膨胀。

## 数据存储
- 消息记录与统计数据：SQLite，位于 localstore 插件数据目录
- 热度图临时文件：渲染后即发即删

## 0.2.0 更新日志

- **修复**：`/群热度` 与 `/昨日热度图` 成功回复后还会追加一条“获取热度失败/生成热度图失败”的报错（`finish()` 抛出的 `FinishedException` 被宽泛的 `except Exception` 捕获所致）
- **修复**：昨日全天无消息时不再输出 -10° 的误导性平线图，正确提示“暂无昨日数据”
- **修复**：Linux 服务器上热度图中文全部显示为方框的问题（自动检测并使用系统可用的中文字体，覆盖 Windows/macOS/Linux 常见字体）
- **修复**：热度图固定文件名导致多个群同时请求时互相覆盖（改为随机文件名，发送后即删）
- **修复**：错误地把发布工具 `twine` 声明为运行时依赖
- 新增消息记录保留期（默认 7 天），启动时与每日凌晨自动清理过期记录，防止数据库无限增长
- 昨日热度统计由 48 次串行查询优化为单次 SQL 分桶聚合；开启 WAL 提升 SQLite 并发性能
- `requires-python` 提升至 3.10，新增测试套件（nonebug + pytest，27 例）

## 开发

```bash
pip install -e ".[test]"
pytest
```

## 开源协议
MIT
