Commit Graph

9 Commits

Author SHA1 Message Date
c62ac37611 review: fix critical/medium bugs in 4 plugins (round 2)
group_horse_racing:
- settle_race: rewrite with 7 bug fixes (race condition, draw double-credit, empty participants, etc.)
- models.py: reorder fields for correct defaults, add indexes
- message_service: add logger import

danding_points:
- api.py: add finally blocks to 3 methods (add_points, get_history, get_leaderboard)
- database.py: add finally block to get_user_balance

chatai:
- __init__.py: deprecated API→asyncio.to_thread, deduplicate logging, taskkill filter for safety
- screenshot.py: XSS protection with bleach on HTML content
- requirements.txt: add bleach dependency

danding_qqpush:
- api.py L13: fix self-referencing _renderer NameError crash
- api.py: lazy singleton pattern via _get_renderer() instead of per-request ImageRenderer
- __init__.py: mask Token in log output (security)

All 34 tests pass.
2026-05-10 00:30:22 +08:00
f240ba2882 perf+fix(danding_qqpush): perf优化+安全修复+代码DRY
- image_render: cached draw object, font.getlength() 替代逐字符创建临时Image
- image_render: 移除PNG无效的quality参数
- api.py: ImageRenderer单例复用(避免每请求重载字体)
- api.py: 异常详情不再泄露到API响应
- sender.py: 提取_send_msg()消除重复代码
2026-05-09 23:46:44 +08:00
c01338f496 refactor(plugins): comprehensive code review - ~35 fixes across 14 plugins
Phase 1 - Plugin code review (14/14 plugins):
- Security: 3x token leak in print→logger.debug, Bearer prefix handling
- Bug: bare except→specific exceptions, HorseState type safety, sync→async
- Critical: response_model undefined, route dead code, sync blocking event loop
- Quality: 11x print()→logger, variable name shadowing, consistent logging

Phase 2 - Deep analysis:
- Fix: payout int truncation→max(1, round(amount*odds))
- Fix: room_store get_lock race condition→dict.setdefault()
- Verify: data_manager f-string SQL is safe (uses ? placeholders)

Infrastructure: review reports generated for all plugins.
2026-05-09 23:22:28 +08:00
2214e22b80 feat: 添加 pilmoji 依赖并支持渲染 emoji 表情
- 在 requirements.txt 中添加 pilmoji==2.0.5 依赖
- 重构 ImageRenderer 类,使用 Pilmoji 替代 PIL 的原生 text 方法以支持渲染 emoji 表情
- 将字体路径配置提取为类常量 DEFAULT_FONT_PATHS,并包含 Windows 和 Linux 的默认路径
- 初始化方法中的 font_paths 参数默认为 None,自动使用默认字体路径列表
2026-04-04 22:27:00 +08:00
45fbb947da fix(image_render): 为字体路径提供默认值
避免在未提供字体路径时出现None值错误,确保渲染器能正常初始化。
默认使用NotoSansCJK-Regular.ttc和NotoColorEmoji.ttf字体文件。
2026-04-04 22:19:49 +08:00
ab1329042a feat(group_horse_racing): 增加赛马消息图片渲染功能
- 在配置中新增图片渲染相关参数:RACE_RENDER_AS_IMAGE、RACE_IMAGE_WIDTH 等
- 复用 danding_qqpush 的 ImageRenderer,使其支持自定义标题
- 在比赛开始、结束和进度播报时,将文本消息转换为带标题的图片发送
- 修复测试用例中的消息发送函数调用
2026-04-04 22:09:53 +08:00
6eed4bf3a2 修复:升级 Pydantic v2 兼容性,修复插件加载错误
- 更新 danding_points 配置使用 pydantic_settings.BaseSettings 和 SettingsConfigDict
- 更新 onmyoji_gacha 配置使用 pydantic_settings.BaseSettings
- 修复 danding_qqpush 配置加载使用 model_validate 替代 parse_obj
- 添加 group_horse_racing 插件的详细 README 文档

这些修复解决了 Pydantic v2 迁移中的导入错误和 API 变更问题。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 22:27:45 +08:00
ef259bd73c 功能:为 danding_qqpush 消息添加标记以支持自动撤回功能 2026-01-25 19:54:32 +08:00
dedc872f1b 功能:通过 HTTP API 实现 Danding_QqPush 插件,用于 QQ 群通知
- 增加了通过外部 HTTP API 向 QQ 群组发送消息的核心功能。
- 实现了对长文本消息的图片渲染,以避免被认定为垃圾信息。
- 支持在消息中提及特定的 QQ 用户。
- 创建了用于 API 令牌和图片渲染设置的配置选项。
- 开发了一个测试脚本以验证 API 功能。
- 对现有代码进行了重构,以提高组织性和可维护性。
2026-01-20 21:19:05 +08:00