fix(qqbot): salvage 4 fixes from #27944 (intent, op 7/9, filename, SILK) - #30843
Merged
Conversation
1. Add INTERACTION intent bit (1<<26) to _send_identify, fixing approval button clicks not being received (INTERACTION_CREATE events were never dispatched by the gateway) 2. Include local cached path in video/file attachment descriptions so the LLM can reference files for re-sending to users 3. Add unit tests (TestIdentifyIntents, TestProcessAttachmentsPathExposure)
1. Handle op 7 (Server Reconnect): close WS to trigger reconnect loop while preserving session for Resume 2. Handle op 9 (Invalid Session): check d value to determine if session is resumable; clear session only when not resumable 3. Remove 4009 from session-clearing set (connection timeout is resumable) 4. Expand fatal close codes: 4001/4002/4010-4014 now stop reconnect immediately instead of retrying uselessly 5. Add unit tests
Add original_name parameter to _download_and_cache, preferring the attachment metadata filename over the CDN URL path basename. Previously files were cached with meaningless QQ CDN hash names (e.g. qqdownload_...oadftnv5), causing ugly filenames when sent back to users. Aligns with qqbot-agent-sdk's AttachmentDownloader.download_document.
_guess_ext_from_data: data[:5] == b"#!SILK" -> data[:6] (6-byte string) _looks_like_silk: data[:4] == b"#!SILK" -> data[:6] The previous slices were too short to ever match the 6-byte "#!SILK" literal, relying entirely on the "#!SILK_V3" (9-byte) and 0x02! (2-byte) fallback paths for SILK format detection.
Contributor
🔎 Lint report:
|
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Salvages 4 of 5 commits from #27944 (@WideLee, commits by walli@tencent.com) onto current main. Deferred the 5th commit — a ~255-line WS-thread architecture rewrite + media send support — for separate review with live testing.
Changes (cherry-picked)
1 << 26) —_send_identify()was missing the INTERACTION bit, so QQ gateway never dispatchedINTERACTION_CREATEand approval button clicks were silently lost._process_attachments()now formats non-image/voice attachments as[video: name (path)]/[file: name (path)]instead of opaque[Attachment: name], so the LLM can reference local paths for send-back.dto pick Resume vs re-Identify. Both were previously ignored._download_and_cache()acceptsoriginal_name, prefers attachment metadatafilenameover the CDN URL hash basename.data[:5]/data[:4]→data[:6]so the 6-byteb"#!SILK"literal can actually match.Deferred (not included)
Commit
310cd3e3b"dedicated WS thread + heartbeat restart + media send support" — moves WS lifecycle to a dedicated daemon thread with its own asyncio loop, switches_token_lockfromasyncio.Locktothreading.Lock, adds sync httpx variants, dispatches inbound messages viarun_coroutine_threadsafe. Substantial concurrency rewrite that supersedes #28167 (8199ec3, magic524's "keep QQBot reconnect loop alive" fix). Wants live gateway validation before merge.Validation
pytest tests/gateway/test_qqbot.pyOriginal PR: #27944
Infographic