Skip to content

[feat] Add reply_with_quote_scope to support per-context quote Control#5245

Open
Luna-channel wants to merge 7 commits intoAstrBotDevs:masterfrom
Luna-channel:feat/reply-quote-scope
Open

[feat] Add reply_with_quote_scope to support per-context quote Control#5245
Luna-channel wants to merge 7 commits intoAstrBotDevs:masterfrom
Luna-channel:feat/reply-quote-scope

Conversation

@Luna-channel
Copy link
Contributor

@Luna-channel Luna-channel commented Feb 19, 2026

Description / 描述

此 PR 为引用回复功能增加了“生效范围”控制。目前 AstrBot 的引用回复是全局生效的,而在实际使用中,部分用户希望在私聊中保持简洁,而在群聊中保留引用以维持上下文连贯。

本更改通过引入 reply_with_quote_scope 配置项,允许用户在 WebUI 中自由选择:全部开启 (all)、仅群聊开启 (group_only)、或仅私聊开启 (private_only)。

Modifications / 改动点

主要改动如下:

  1. 核心配置定义 (astrbot/core/config/default.py):
  • 在 DEFAULT_CONFIG 中新增 reply_with_quote_scope 默认值。
  • 在配置元数据中添加了描述、选项标签及联动约束。
  1. 流程逻辑控制 (astrbot/core/pipeline/):
  • 修改 result_decorate/stage.py,通过 event.get_message_type() 识别对话环境,并根据 scope 设置决定是否启用引用。
  1. 国际化支持 (dashboard/src/i18n/):
  • 补全了 zh-CN 和 en-US 的 config-metadata.json 翻译词条,确保 WebUI 能够正确渲染标签。

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

图片 W}}}OY`718TLMHAC$THRCV7 }9JG}FXK2_NA3%LCTHY_NZ3

⚠️ 特别说明 / Note on Screenshots:
由于我本地 Docker 部署环境的前端编译缓存及网络问题,导致 WebUI 预览图中部分新增字段显示为 [MISSING: ...] 变量名。
但我已在源代码(zh-CN.json / en-US.json)中补齐了所有对应的翻译条目。 经代码逻辑自检,在生产环境正常构建后,UI 将恢复正确的中文/英文显示。

  • 环境验证:经测试,当设置为“仅群聊”时,群内消息正常引用回复,私聊消息不触发引用。
  • UI 联动:WebUI 下拉筛选框功能正常,condition 逻辑生效。

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txt 和 pyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

由 Sourcery 提供的摘要

为不同会话类型的“引用回复”行为新增可配置的范围控制。

新功能:

  • 引入 reply_with_quote_scope 配置项,可将引用回复启用为适用于所有聊天、仅群组、或仅私聊。

增强改进:

  • 更新消息处理流水线,使其在保留现有引用行为默认设置的同时,遵循配置的引用回复范围。

文档:

  • 在英文和中文 WebUI 配置中,为新的引用回复范围选项新增 i18n 元数据条目。
Original summary in English

Summary by Sourcery

Add configurable scope control for reply-with-quote behavior across different conversation types.

New Features:

  • Introduce reply_with_quote_scope configuration to enable quote replies for all chats, groups only, or private chats only.

Enhancements:

  • Update message processing pipeline to honor the configured quote reply scope while preserving existing quote behavior defaults.

Documentation:

  • Add i18n metadata entries for the new quote reply scope option in both English and Chinese WebUI configurations.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 19, 2026
@dosubot
Copy link

dosubot bot commented Feb 19, 2026

Related Documentation

Checked 1 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我给出了一些整体性的反馈:

  • reply_with_quote_scope 的取值("all""group_only""private_only")在多处以原始字符串形式重复出现;建议将它们集中定义成常量或枚举风格的定义,以避免拼写错误,并让未来的修改更加安全。
  • is_private 的判断逻辑是明确依赖 MessageType.FRIEND_MESSAGE 的;如果之后新增了消息类型(例如临时会话、频道等),建议要么显式处理这些类型,要么在文档中说明这些类型在引用范围(quote scope)方面应该如何对待。
  • 在流水线阶段中,reply_with_quote_scope 的兜底默认值被硬编码为 "all";相较于重复使用字面量,复用已配置的默认值(来自 DEFAULT_CONFIG)可能会更安全。
给 AI Agent 的提示词
Please address the comments from this code review:

## Overall Comments
- The `reply_with_quote_scope` values (`"all"`, `"group_only"`, `"private_only"`) are duplicated as raw strings in multiple places; consider centralizing them as constants/enum-like definitions to avoid typos and make future changes safer.
- The `is_private` check relies specifically on `MessageType.FRIEND_MESSAGE`; if new message types (e.g., temporary sessions, channels) are added later, consider handling them explicitly or documenting how they should be treated with respect to quote scope.
- The fallback default for `reply_with_quote_scope` is hardcoded as `"all"` in the pipeline stages; it might be safer to reuse the configured default (from `DEFAULT_CONFIG`) instead of repeating the literal.

Sourcery 对开源项目是免费的——如果你觉得我们的 Review 有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的 Review。
Original comment in English

Hey - I've left some high level feedback:

  • The reply_with_quote_scope values ("all", "group_only", "private_only") are duplicated as raw strings in multiple places; consider centralizing them as constants/enum-like definitions to avoid typos and make future changes safer.
  • The is_private check relies specifically on MessageType.FRIEND_MESSAGE; if new message types (e.g., temporary sessions, channels) are added later, consider handling them explicitly or documenting how they should be treated with respect to quote scope.
  • The fallback default for reply_with_quote_scope is hardcoded as "all" in the pipeline stages; it might be safer to reuse the configured default (from DEFAULT_CONFIG) instead of repeating the literal.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `reply_with_quote_scope` values (`"all"`, `"group_only"`, `"private_only"`) are duplicated as raw strings in multiple places; consider centralizing them as constants/enum-like definitions to avoid typos and make future changes safer.
- The `is_private` check relies specifically on `MessageType.FRIEND_MESSAGE`; if new message types (e.g., temporary sessions, channels) are added later, consider handling them explicitly or documenting how they should be treated with respect to quote scope.
- The fallback default for `reply_with_quote_scope` is hardcoded as `"all"` in the pipeline stages; it might be safer to reuse the configured default (from `DEFAULT_CONFIG`) instead of repeating the literal.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dosubot dosubot bot added area:core The bug / feature is about astrbot's core, backend area:webui The bug / feature is about webui(dashboard) of astrbot. labels Feb 19, 2026
@Luna-channel Luna-channel changed the title [feat] Add reply_with_quote_scope to support per-context quote control [feat] Add reply_with_quote_scope to support per-context quote Control Feb 19, 2026
@Luna-channel Luna-channel reopened this Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core The bug / feature is about astrbot's core, backend area:webui The bug / feature is about webui(dashboard) of astrbot. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments