feat: 缓存目录可配置与过期清理、reply 三层解析、接收方向转发自动合并 - #112
Merged
This-is-XiaoDeng merged 5 commits intoAug 14, 2026
Merged
Conversation
- system.cache_dir 支持修改缓存目录(默认 .cache),database 未配置时自动使用缓存目录下的 onedisc.db - system.cache 支持配置 files/url_cache/db 三类缓存过期时间(默认不过期)与清理间隔,启动后定时自动清理 - reply 段解析升级为三层:cached_messages → 本地 DB → 同频道 REST 预检 - 接收方向(Discord → OneBot)转发消息自动合并:同一频道同一发送者窗口内(默认 500ms)的转发合并为一条 forward 上报,get_forward_msg 通过第一条消息调 Discord API 拉取上下文无状态重建 - 测试:test_cache_and_reply(10 例)、test_forward_merge(33 例)、test_native_forward(13 例)全部通过 - docs/config.md 与 docs/diff-v11.md 同步更新
- 根目录 test_*.py 移入 tests/,改写为 pytest 风格(async def + assert),新增 conftest.py(CI 环境自动创建 dummy config.json、清理 .cache 副作用) - pyproject.toml 新增 [tool.pytest.ini_options](testpaths/pythonpath/asyncio_mode)与 test 依赖组(pytest、pytest-asyncio) - ci.yml 新增 test job:poetry install --only main,test + pytest(不装 nuitka 等构建依赖) - 本地验证 40 例全部通过
This-is-XiaoDeng
merged commit Aug 14, 2026
91a38f5
into
ITCraftDevelopmentTeam:master
2 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动内容
system.cache_dir(默认.cache),全部硬编码路径替换为utils/cache.py助手;database未配置时自动使用缓存目录下的onedisc.db(替换原:memory:默认,避免重启丢失)system.cache配置(files_ttl/url_cache_ttl/db_ttl/cleanup_interval,默认不过期),启动后定时清理,清理逻辑避开索引 jsonMessage表构造discord.MessageReference)→ 同频道 REST 预检,失败维持警告+忽略merge_forward_interval,默认 500ms)的 Discord 转发消息自动合并为一条 OneBot V11 forward 上报;get_forward_msg动作通过第一条消息(id 编码「频道id_消息id」)调 Discord API 拉取上下文重建(含翻页),无状态、重启不丢;system.merge_forward可开关(默认开启)tests/目录并 pytest 化(conftest.py自动处理 CI 无配置文件环境),新增 test 依赖组与独立test.ymlworkflow(PR + master 触发)测试
tests/test_cache_and_reply.py:10 例tests/test_forward_merge.py:18 例(含翻页拉取、序列中断、非法 id)tests/test_native_forward.py:12 例(回归)testworkflow)全部通过文档
docs/config.md:database / cache_dir / cache / merge_forward / merge_forward_interval 配置说明docs/diff-v11.md:get_forward_msg由「不支持」更正为「仅支持查询自动合并产生的消息」