From 60b0a0e00671f8bb809b57cf73fbf90a07803ec4 Mon Sep 17 00:00:00 2001 From: walli Date: Mon, 18 May 2026 18:42:43 +0800 Subject: [PATCH] fix(qqbot): fix SILK magic byte detection slice length _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. --- gateway/platforms/qqbot/adapter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/platforms/qqbot/adapter.py b/gateway/platforms/qqbot/adapter.py index ddbffa46238..2c2124c56ef 100644 --- a/gateway/platforms/qqbot/adapter.py +++ b/gateway/platforms/qqbot/adapter.py @@ -1942,7 +1942,7 @@ class QQAdapter(BasePlatformAdapter): @staticmethod def _guess_ext_from_data(data: bytes) -> str: """Guess file extension from magic bytes.""" - if data[:9] == b"#!SILK_V3" or data[:5] == b"#!SILK": + if data[:9] == b"#!SILK_V3" or data[:6] == b"#!SILK": return ".silk" if data[:2] == b"\x02!": return ".silk" @@ -1962,7 +1962,7 @@ class QQAdapter(BasePlatformAdapter): @staticmethod def _looks_like_silk(data: bytes) -> bool: """Check if bytes look like a SILK audio file.""" - return data[:4] == b"#!SILK" or data[:2] == b"\x02!" or data[:9] == b"#!SILK_V3" + return data[:6] == b"#!SILK" or data[:2] == b"\x02!" or data[:9] == b"#!SILK_V3" async def _convert_silk_to_wav(self, src_path: str, wav_path: str) -> Optional[str]: """Convert audio file to WAV using the pilk library.