From ba1acd624ec6650ee578eb5d363f22b122aff4e9 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: Fri, 16 May 2025 21:21:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BF=81=E7=A7=BBat=20=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/onebot/api/msg.ts | 51 +++++++++++++++++++------------------ src/onebot/types/message.ts | 2 +- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/onebot/api/msg.ts b/src/onebot/api/msg.ts index e7695ebb..4579b1b1 100644 --- a/src/onebot/api/msg.ts +++ b/src/onebot/api/msg.ts @@ -94,15 +94,16 @@ export class OneBotMsgApi { }; } else { let qq: string = 'all'; + const { atNtUid, atUid, content } = element; if (element.atType !== NTMsgAtType.ATTYPEALL) { - const { atNtUid, atUid } = element; + qq = !atUid || atUid === '0' ? await this.core.apis.UserApi.getUinByUidV2(atNtUid) : String(Number(atUid) >>> 0); } return { type: OB11MessageDataType.at, data: { - qq: qq, - // name: content.slice(1); + id: qq, + name: content.slice(1) }, }; } @@ -514,7 +515,7 @@ export class OneBotMsgApi { }, }), - [OB11MessageDataType.at]: async ({ data: { qq: atQQ } }, context) => { + [OB11MessageDataType.at]: async ({ data: { id: atQQ } }, context) => { function at(atUid: string, atNtUid: string, atType: NTMsgAtType, atName: string): SendTextElement { return { elementType: ElementType.TEXT, @@ -936,7 +937,7 @@ export class OneBotMsgApi { const validSegments = await this.parseMessageSegments(msg, parseMultMsg); resMsg.message = validSegments; - return { arrayMsg: resMsg }; + return { arrayMsg: resMsg }; } private initializeMessage(msg: RawMessage): OB11Message { @@ -1070,16 +1071,16 @@ export class OneBotMsgApi { const calculateTotalSize = async (elements: SendMessageElement[]): Promise => { const sizePromises = elements.map(async element => { switch (element.elementType) { - case ElementType.PTT: - return (await fsPromise.stat(element.pttElement.filePath)).size; - case ElementType.FILE: - return (await fsPromise.stat(element.fileElement.filePath)).size; - case ElementType.VIDEO: - return (await fsPromise.stat(element.videoElement.filePath)).size; - case ElementType.PIC: - return (await fsPromise.stat(element.picElement.sourcePath)).size; - default: - return 0; + case ElementType.PTT: + return (await fsPromise.stat(element.pttElement.filePath)).size; + case ElementType.FILE: + return (await fsPromise.stat(element.fileElement.filePath)).size; + case ElementType.VIDEO: + return (await fsPromise.stat(element.videoElement.filePath)).size; + case ElementType.PIC: + return (await fsPromise.stat(element.picElement.sourcePath)).size; + default: + return 0; } }); const sizes = await Promise.all(sizePromises); @@ -1169,16 +1170,16 @@ export class OneBotMsgApi { groupChangDecreseType2String(type: number): GroupDecreaseSubType { switch (type) { - case 130: - return 'leave'; - case 131: - return 'kick'; - case 3: - return 'kick_me'; - case 129: - return 'disband'; - default: - return 'kick'; + case 130: + return 'leave'; + case 131: + return 'kick'; + case 3: + return 'kick_me'; + case 129: + return 'disband'; + default: + return 'kick'; } } diff --git a/src/onebot/types/message.ts b/src/onebot/types/message.ts index ab427b18..e2cbf481 100644 --- a/src/onebot/types/message.ts +++ b/src/onebot/types/message.ts @@ -143,7 +143,7 @@ export interface OB11MessageVideo extends OB11MessageFileBase { export interface OB11MessageAt { type: OB11MessageDataType.at; data: { - qq: string; // `${number}` | 'all' + id: string; // `${number}` | 'all' name?: string; }; }