Skip to content

feat(aiocqhttp): make self-mention stripping configurable - #10157

Open
PeiPei233 wants to merge 1 commit into
AstrBotDevs:masterfrom
PeiPei233:feat/aiocqhttp-strip-self-mention
Open

PeiPei233 wants to merge 1 commit into
AstrBotDevs:masterfrom
PeiPei233:feat/aiocqhttp-strip-self-mention

Conversation

@PeiPei233

@PeiPei233 PeiPei233 commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

When a group message mentions several bots, the OneBot v11 adapter removes this bot's first mention from each contiguous mention group while retaining other mentions in message_str. An LLM consuming that text can therefore interpret a message addressed to multiple bots as addressed only to the other bots.

Add a per-adapter strip_self_mention toggle to the OneBot v11 configuration. It defaults to true, including for existing configurations without the key, preserving current wake-prefix and command-matching behavior. Turning it off retains the bot's mention name and ID in the message text. Structured At components remain intact in both modes.

Includes Chinese and English setting descriptions and platform documentation. The setting hint notes that retaining mentions also affects commands matched against message text. This change does not attempt to infer model intent or filter invisible-only responses.

Validation:

  • 33 related OneBot tests passed, including 18 new cases covering missing/enabled/disabled configuration, self-only and multiple-bot mentions, repeated self-mentions, and whitespace-separated mention groups.
  • ruff format . and ruff check . passed in an isolated source copy using the existing container's dependencies.
  • Both modified locale JSON files parse successfully; git diff --check passed.

Summary by Sourcery

Make OneBot v11 self-mention stripping configurable while preserving legacy behavior by default.

New Features:

  • Add a configurable OneBot v11 option for retaining or removing the bot’s self-mentions from plain-text message content.

Enhancements:

  • Preserve structured mention components and existing default wake-prefix behavior while allowing self-mention names and IDs to remain visible to models and text-based command matching.

Documentation:

  • Document the self-mention setting and its effects in English and Chinese platform guides and configuration metadata.

Tests:

  • Add coverage for default, enabled, and disabled settings across self-only, multiple-bot, repeated, and separated mention patterns.

Copilot AI lite review requested due to automatic review settings September 20, 2026 12:33

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation, defaults, documentation, localization, and targeted tests consistently cover the requested behavior.

Review effort: Lite
Findings: None

What changed in this PR

Adds configurable OneBot v11 self-mention stripping while preserving existing behavior by default.

Changes:

  • Adds strip_self_mention configuration with default-enabled compatibility behavior.
  • Preserves structured At components and documents the setting in Chinese and English.
  • Adds parameterized coverage for mention configurations and grouping.
File Description
astrbot/​core/​platform/​sources/​aiocqhttp/​aiocqhttp_platform_adapter.py Applies configurable self-mention text handling.
astrbot/​core/​config/​default.py Defines the setting and default metadata.
tests/​unit/​test_aiocqhttp_self_mention.py Tests enabled, disabled, and missing configuration cases.
dashboard/​src/​i18n/​locales/​en-US/​features/​config-metadata.json Adds English setting text.
dashboard/​src/​i18n/​locales/​zh-CN/​features/​config-metadata.json Adds Chinese setting text.
docs/​en/​platform/​aiocqhttp.md Documents the English configuration option.
docs/​zh/​platform/​aiocqhttp.md Documents the Chinese configuration option.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants