Repository navigation
Conversation
…lattened quoted images QQ tags a passive reply with message_type 103 and puts the previous message into msg_elements even when the user only @-mentioned the bot. The adapter built a Reply whenever that echo produced any text, so quote-preferring plugins started verifying a message nobody had quoted. A quoted message id is what distinguishes a real quote from the echo, so the Reply is now built only when message_reference.message_id or the quoted element's own id is present. The echo text is dropped rather than presented as a quote. QQ also pre-renders a quoted attachment into the quoted text as an [附件N] 类型:图片 ... URL:<url> line and leaves attachments empty, so quoted images reached plugins as prose. Those lines are lifted back into Image components and removed from the text. A populated attachments list still wins, so the existing path is unchanged.
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py" line_range="723-726" />
<code_context>
+ #: QQ renders a quoted attachment into the quoted text as
+ #: ``[附件N] 类型:图片 ... URL:<url>`` and leaves ``attachments`` empty, so the
+ #: image would otherwise reach plugins as unstructured prose.
+ _FLATTENED_IMAGE_LINE_RE = re.compile(
+ r"^\[附件\d+\]\s*类型:图片\b[^\n]*?URL:(\S+)[^\n]*\n?",
+ re.MULTILINE,
+ )
+
+ @staticmethod
</code_context>
<issue_to_address>
**Matching prose becomes an image**
When a quoted message contains literal text matching the attachment-line pattern, `_extract_flattened_quoted_images` treats any quoted-content line matching this pattern as QQ attachment metadata, removes it from the text, and returns its URL as an image. A user-authored line that happens to match the format is therefore misrepresented as an image instead of quoted literally.
Only lift lines when their attachment-metadata origin can be distinguished from ordinary quoted text; otherwise preserve ambiguous lines as text.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py:726
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@Soulter @clown145 Current master is merged in Could you review the narrowed quote rule? A passive |
Refs #10840.
Problem
A passive reply can arrive with
message_type=103and the previous message inmsg_elementseven when the user did not quote it. Treating the presence of quoted text as sufficient to create aReplycauses quote-preferring plugins to process the wrong message.Fix
Replyonly whenmessage_reference.message_idor the quoted element's ownid/message_idis present.contentalone cannot distinguish QQ-generated metadata from a user-authored line with the same spelling. No image is inferred without structured attachment provenance.This narrows the change to identifiable quotes and avoids altering ambiguous user text. Recovering flattened images needs an upstream provenance signal and is not claimed by this PR.
Verification
878f40dc6cbcb88a08a3099112d555faae572d8c,tests/test_qqofficial_group_message_create.pypasses 50 tests, and all eight QQOfficial test modules pass 144 tests under Python 3.12.12. This includes the passive-echo, explicit quote ID, structured attachment, literal text, ordered mention, and webhook cases.git diff --checkpass. The full staged merge diff also exposes pre-existing whitespace in unrelated upstream documentation; those files are not changed by this PR.f790a032d118390f3dc2e24c3e009f7e05fcfe70passed all 23 hosted checks. Current master841295fa938d2cd028b9e0cb832f293c5c5c0d4bis merged without a rebase or force push. No live QQ traffic, credentials, or network path was exercised locally.Checklist
AI Assistance Disclosure
Claude Code assisted with investigating the issue, implementing the fix, and running the regression checks.
Summary by Sourcery
Require explicit quote identifiers in QQOfficial messages to prevent false replies and preserve ambiguous quoted content.
Bug Fixes:
Tests: