refactor(repeater): P5 拆分 + M3 L2 元数据热重载#219
Merged
Merged
Conversation
__init__ 仅保留元数据、生命周期绑定与对外 re-export;
matcher/调度逻辑迁至 handlers/{message,ban,scheduler,lifecycle,helpers}。
行为不变,fanout 仍 lazy import 避免循环依赖。
- reload_plugin_metadata_l2 重建 ingress/help/storage/cmd_perm 缓存 - WebUI 插件配置保存后对 reload_policy metadata/full 触发 L2 - env_sections 延迟导入 plugin_package_aliases 修复循环依赖
Contributor
There was a problem hiding this comment.
Hey - 我给出了一些整体性的反馈:
- 当前针对封禁目标的 CQ 码规范化逻辑(用于消息中循环/
try_convert_to_cqcode的正则表达式和循环)在extract_ban_reply_raw_from_message和handlers/ban.py中的召回处理器里各实现了一遍;建议抽取一个共享的辅助函数,把解析规则集中到一个地方维护。 - 在
reload_policy_for_plugin_name中,查找逻辑是直接用plugin.name与 WebUI 的plugin_name做匹配;如果在其他地方使用了别名或带点号的包路径(例如规范化后的名称),为了避免策略不一致,可能更安全的做法是先进行统一规范化,或是改为与PluginMetadata.name对比。
给 AI Agent 的提示词
Please address the comments from this code review:
## Overall Comments
- The CQ-code normalization logic for ban targets (the regex and loop over message/`try_convert_to_cqcode`) is now duplicated between `extract_ban_reply_raw_from_message` and the recall handler in `handlers/ban.py`; consider extracting a shared helper to keep the parsing rules in one place.
- In `reload_policy_for_plugin_name`, the lookup matches `plugin.name` directly against the WebUI `plugin_name`; if aliases or dotted package paths are used elsewhere (e.g., canonicalized names), it may be safer to normalize or compare against `PluginMetadata.name` to avoid policy mismatches.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进以后的 Review。
Original comment in English
Hey - I've left some high level feedback:
- The CQ-code normalization logic for ban targets (the regex and loop over message/
try_convert_to_cqcode) is now duplicated betweenextract_ban_reply_raw_from_messageand the recall handler inhandlers/ban.py; consider extracting a shared helper to keep the parsing rules in one place. - In
reload_policy_for_plugin_name, the lookup matchesplugin.namedirectly against the WebUIplugin_name; if aliases or dotted package paths are used elsewhere (e.g., canonicalized names), it may be safer to normalize or compare againstPluginMetadata.nameto avoid policy mismatches.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The CQ-code normalization logic for ban targets (the regex and loop over message/`try_convert_to_cqcode`) is now duplicated between `extract_ban_reply_raw_from_message` and the recall handler in `handlers/ban.py`; consider extracting a shared helper to keep the parsing rules in one place.
- In `reload_policy_for_plugin_name`, the lookup matches `plugin.name` directly against the WebUI `plugin_name`; if aliases or dotted package paths are used elsewhere (e.g., canonicalized names), it may be safer to normalize or compare against `PluginMetadata.name` to avoid policy mismatches.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
- 抽取 normalize_cq_ban_token / ban_raw_from_recalled_api_payload - reload_policy 查找经 canonical_plugin_package 对齐旧包名别名
TogetsuDo
added a commit
that referenced
this pull request
Jun 16, 2026
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.
Summary
repeater/__init__.py拆至handlers/(message / ban / scheduler / lifecycle / helpers),行为不变reload_plugin_metadata_l2()重建 ingress / help / storage / cmd_perm 索引reload_policy: metadata|full自动触发 L2env_sections延迟导入plugin_package_aliases避免循环依赖Test plan
pytest tests/features/test_plugin_reload*.py tests/plugins/repeater/test_ban_target.pyruff check通过Summary by Sourcery
将 repeater 插件重构为独立的处理程序模块,并新增 L2 插件元数据热重载机制,在 WebUI 配置保存后重建运行时索引。
Enhancements(增强):
reload_policy触发重载,支持metadata/full等策略。Documentation(文档):
Tests(测试):
Original summary in English
Summary by Sourcery
Refactor the repeater plugin into dedicated handler modules and add L2 plugin metadata hot-reload that rebuilds runtime indices after WebUI config saves.
Enhancements:
Documentation:
Tests: