Repository navigation
fix(qq): deliver a voice message as the platform's ASR text - #1827
Conversation
A QQ voice event carries no `content`. The adapter normalised every inbound event to `text: String(d.content ?? '').trim()` and hard-coded `images: [], files: []`, so a voice message became an empty text and the common IM entry dropped it before it reached the Bot (Fei2411#1824). The transcript is already on the wire: each voice attachment carries the platform's own ASR result in `asr_refer_text`. `textOf()` now falls back to the joined transcript of every voice attachment when `content` is empty, and keeps a typed caption ahead of it when the sender wrote one. Refs Fei2411#1824
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
Fei2411
left a comment
There was a problem hiding this comment.
Verdict: Approve. Fixes #1824.
With textOf(d), a caption still wins. A voice message with no content now delivers its asr_refer_text, and several voice attachments are joined with newlines. Non-voice attachments and a voice attachment without ASR text produce no text, so an empty message is still treated as before.
Local check, merged onto current dev: im-qq (13/13) and im (59/59) pass, lint and build-client --check are clean, and all CI checks are green. As you noted, it has not been checked against a live QQ account.
Overlap: #1201 also edits src/host/im/platforms/qq.js and conflicts with this PR, but it does not handle voice ASR, so this PR is not a duplicate.
Issue
Fixes #1824
What changed / 改了什么
ds-bot/src/host/im/platforms/qq.js: inbound normalisation now derivestextfrom atextOf(d)helper instead ofString(d.content ?? '').trim().Root cause. A QQ voice message carries no
content. The adapter tookcontentas the only text source, so a voice event normalised totext: ''; the common IM entry then returned beforert.sendUserand the message disappeared without a log line. The transcript never had to be fetched — QQ already puts its own ASR result on the attachment asasr_refer_text.Mechanism.
textOf(d)keeps the sender's owncontentwhen it is non-empty (a caption typed alongside the voice still wins), and otherwise joins the trimmedasr_refer_textof everycontent_type === 'voice'attachment. A voice attachment with no ASR text still yields'', so the downstream "no text" path is unchanged rather than newly short-circuited here.Images and incoming files are deliberately out of scope: they need an upload/download path, not a normalisation change. This PR is only the text channel of the voice event.
Changelog
Voice messages sent to a Bot over QQ now reach the Bot as the platform's own transcription instead of being dropped silently.
How I checked it / 怎么验证的
npm test(inds-bot/), see the boundary note below for what I could runnode scripts/build-client.mjs --check— not run:qq.jsis host-side, not part of the client bundlenpm run lint— not runnable here: it needs a checked-outdeepseek-harnesswith its packages installedThree cases added to
test/im-qq.test.js, driven through the existing fake gateway + fake socket harness:content: ''andasr_refer_text: '明天下午三点开会'→msg.textis that text. Red before the fix ('' !== '明天下午三点开会'), green after.asr_refer_text→text: ''; the event still reachesonMessage(guards the "dropped before delivery" half of the report).Evidence boundary: reverse check is a real one — I reverted
textOf(d)back to the old expression, kept the new tests, and exactly case 1 failed (12/13); restoring the fix gave 13/13. The wider IM group (im-qq,im-qq-markdown,im-format,im-discord) is 37/37 green;im-telegram.test.jsfails to load in this checkout because the@deepseek-ai/dsh-llmpackage is not installed here, which is unrelated to this change (it imports nothing fromqq.js).Not verified: a real QQ voice event end to end. The field name and the
content_type === 'voice'discriminator come from the officialMessageAttachmenttable quoted in the report, and the payload shape used in the tests copies it.