fix(qqofficial): use appid self id for incoming messages#8522
fix(qqofficial): use appid self id for incoming messages#8522FlanChanXwO wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the QQ Official platform adapters to use the configured appid instead of hardcoded strings (like "qq_official" or "unknown_selfid") for identifying the bot (self_id) and when appending At components. It also adds comprehensive unit tests for these changes. A review comment points out a potential runtime crash if appid is configured as an integer, suggesting to coerce it to a string inside _parse_from_qqofficial to ensure robustness.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| appid: str, | ||
| ) -> AstrBotMessage: | ||
| abm = AstrBotMessage() |
There was a problem hiding this comment.
If the user configures appid as an integer in the configuration file (e.g., appid: 123456 in YAML), appid will be passed as an int. This will cause a TypeError when performing string concatenation (e.g., "<@!" + appid + ">") in channel/direct message parsing, leading to a runtime crash.
Coercing appid to a string at the beginning of _parse_from_qqofficial ensures robustness against different configuration types.
| appid: str, | |
| ) -> AstrBotMessage: | |
| abm = AstrBotMessage() | |
| appid: str, | |
| ) -> AstrBotMessage: | |
| appid = str(appid) | |
| abm = AstrBotMessage() |
Summary
self_idso downstream code can resolve bot identity/avatar data consistentlyAtcomponent for group/channel messages and avoid polluting direct/C2C messages<@!appid>mention from text content after preserving the structuredAtcomponentRelation to existing PR
This is the narrowed replacement for #7289 / #6741. The existing
feat/6741branch is currently conflicting and contains a large amount of unrelated historical changes. The fork branch is protected against force-push, so this PR keeps only the current QQ official appid/self_id/At fix in a clean branch.Validation
../AstrBot/.venv/bin/python -m pytest tests/test_qqofficial_adapter.py -q../AstrBot/.venv/bin/ruff check astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_adapter.py tests/test_qqofficial_adapter.py../AstrBot/.venv/bin/ruff format --check astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_adapter.py tests/test_qqofficial_adapter.pyDuplicate check
Checked open upstream QQ official PRs. #7289 is the previous broad/conflicting version from this fork; other open QQ official PRs target keyboard support, image upload, duplicate consumption, proactive markdown sends, or friend-message send payloads, so no other same-scope PR was found.
Summary by Sourcery
Align QQ Official incoming message parsing with the appid-based bot identity model.
Bug Fixes:
Tests: