diff --git a/packages/core/src/bridge/apis/extras.ts b/packages/core/src/bridge/apis/extras.ts index d142ac20..56b14d47 100644 --- a/packages/core/src/bridge/apis/extras.ts +++ b/packages/core/src/bridge/apis/extras.ts @@ -31,15 +31,6 @@ export interface PttTransInput { fileId?: number; } -function hexToBytes(hex: string): Uint8Array { - const s = (hex || '').trim(); - if (!s) return new Uint8Array(0); - const len = s.length >> 1; - const out = new Uint8Array(len); - for (let i = 0; i < len; i++) out[i] = parseInt(s.substr(i * 2, 2), 16); - return out; -} - // ─────────────── public types (re-exported from bridge.ts as before) ─── export type StrangerStatus = NamespaceStrangerStatus; @@ -131,10 +122,13 @@ export class ExtrasApi { * already-transcribed case). For a freshly-received voice the response is an * empty ack and the text is delivered later via the async Event 0x210 * subType-61 push — callers should treat `''` as "pending" and wait for the - * `ptt_trans_result` event (correlated by msgId). Live-verified end to end. + * `ptt_trans_result` event (correlated by msgId). */ async translatePttToText(input: PttTransInput): Promise { - const md5 = hexToBytes(input.md5Hex); + // QQ NT sends the md5 as a 32-char lowercase HEX STRING, not the raw 16 + // bytes (RE'd from wrapper.linux.node EncodeTroopPtt/EncodeC2CPtt: the md5 + // field goes through a bytes→hex helper). Sending raw bytes → errCode -1079. + const md5 = input.md5Hex.toLowerCase(); const req: PttTransReq = input.isGroup ? { type: 1, diff --git a/packages/proto-defs/src/ptt-trans.ts b/packages/proto-defs/src/ptt-trans.ts index 3290d581..b5460317 100644 --- a/packages/proto-defs/src/ptt-trans.ts +++ b/packages/proto-defs/src/ptt-trans.ts @@ -1,4 +1,4 @@ -import type { pb, uint_32, uint_64, bytes } from '@snowluma/proton'; +import type { pb, uint_32, uint_64 } from '@snowluma/proton'; /** * Voice-to-text (语音转文字) request/response protobufs for the @@ -28,7 +28,11 @@ export interface C2CPttTransItem { size?: pb<6, uint_32>; // element 45405 (bytes) format?: pb<7, uint_32>; // element 45907 (voice codec) eventType?: pb<8, uint_32>; // element 45921 - md5?: pb<9, bytes>; // element 45406 (raw 16-byte md5) + // QQ NT (EncodeC2CPtt) hex-encodes the md5 to a 32-char lowercase string + // before sending it (verified in wrapper.linux.node: field 9 = sub_7A02D80 + // = bytes→hex). Sending the raw 16 bytes makes the server reject with + // errCode -1079. So this is a hex STRING, not bytes. + md5?: pb<9, string>; // element 45406 (32-char lowercase hex) } export interface GroupPttTransItem { @@ -36,7 +40,7 @@ export interface GroupPttTransItem { senderUin?: pb<2, uint_64>; groupUin?: pb<3, uint_64>; fileId?: pb<4, uint_32>; // element 45903 (group ptt numeric file id) - md5?: pb<5, bytes>; // element 45406 + md5?: pb<5, string>; // element 45406 (32-char lowercase hex, see C2C note) duration?: pb<6, uint_32>; // element 45906 size?: pb<7, uint_32>; // element 45405 format?: pb<8, uint_32>; // element 45907