From 255491a107600e08abe7a3df2bf6d3f0acf2d78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 8 Sep 2024 10:41:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20hex=E8=AE=A1=E7=AE=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/helper.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/helper.ts b/src/common/helper.ts index e7b767b1..59c771aa 100644 --- a/src/common/helper.ts +++ b/src/common/helper.ts @@ -29,7 +29,7 @@ export class FileNapCatOneBotUUID { const data = `NapCatOneBot|ModelIdFile|${peer.chatType}|${peer.peerUid}|${modelId}|${fileId}`; //前四个字节塞data长度 const length = Buffer.alloc(4 + data.length); - length.writeUInt32BE(data.length, 0); + length.writeUInt32BE(data.length * 2, 0);//储存data的hex长度 length.write(data, 4); return length.toString('hex') + endString; } @@ -62,8 +62,9 @@ export class FileNapCatOneBotUUID { static encode(peer: Peer, msgId: string, elementId: string, endString: string = ""): string { const data = `NapCatOneBot|MsgFile|${peer.chatType}|${peer.peerUid}|${msgId}|${elementId}`; //前四个字节塞data长度 + //一个字节8位 一个ascii字符1字节 一个hex字符4位 表示一个ascii字符需要两个hex字符 const length = Buffer.alloc(4 + data.length); - length.writeUInt32BE(data.length, 0); + length.writeUInt32BE(data.length * 2, 0); length.write(data, 4); return length.toString('hex') + endString; }