From 2d1e87defc5d9c82ddbe1208af2f73ab1500ef91 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: Thu, 15 Aug 2024 19:34:05 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F?= =?UTF-8?q?=E6=8F=90=E9=AB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/apis/msg.ts | 4 ++-- src/core/entities/msg.ts | 8 +++++++- src/onebot/index.ts | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/apis/msg.ts b/src/core/apis/msg.ts index 45762821..0cb8774a 100644 --- a/src/core/apis/msg.ts +++ b/src/core/apis/msg.ts @@ -1,4 +1,4 @@ -import { ChatType, GetFileListParam, Peer, RawMessage, SendMessageElement } from '@/core/entities'; +import { ChatType, GetFileListParam, Peer, RawMessage, SendMessageElement, SendStatusType } from '@/core/entities'; import { InstanceContext, NapCatCore } from '@/core'; import { onGroupFileInfoUpdateParamType } from '@/core/listeners'; import { GeneralCallResult } from '@/core/services/common'; @@ -171,7 +171,7 @@ export class NTQQMsgApi { timeout, (msgRecords: RawMessage[]) => { for (const msgRecord of msgRecords) { - if (msgRecord.guildId === msgId && msgRecord.sendStatus === 2) { + if (msgRecord.guildId === msgId && msgRecord.sendStatus === SendStatusType.KSEND_STATUS_SUCCESS) { return true; } } diff --git a/src/core/entities/msg.ts b/src/core/entities/msg.ts index e5687ca4..01f4a050 100644 --- a/src/core/entities/msg.ts +++ b/src/core/entities/msg.ts @@ -891,6 +891,12 @@ export enum NTSubMsgType { KMSGSUBTYPEMIXTEXT = 0, KMSGSUBTYPETENCENTDOC = 6 } +export enum SendStatusType { + KSEND_STATUS_FAILED = 0, + KSEND_STATUS_SENDING = 1, + KSEND_STATUS_SUCCESS = 2, + KSEND_STATUS_SUCCESS_NOSEQ = 3 +} export interface RawMessage { parentMsgPeer: Peer; @@ -950,7 +956,7 @@ export interface RawMessage { /** * 消息状态,别人发的 2 是已撤回,自己发的 2 是已发送 */ - sendStatus?: number; + sendStatus?: SendStatusType; /** * 撤回时间,"0" 是没有撤回 diff --git a/src/onebot/index.ts b/src/onebot/index.ts index 302ff3e4..f7a90a42 100644 --- a/src/onebot/index.ts +++ b/src/onebot/index.ts @@ -8,6 +8,7 @@ import { MsgListener, NapCatCore, RawMessage, + SendStatusType, } from '@/core'; import { OB11Config, OB11ConfigLoader } from '@/onebot/helper/config'; import { OneBotApiContextType } from '@/onebot/types'; @@ -250,7 +251,7 @@ export class NapCatOneBot11Adapter { .catch(e => this.context.logger.logError('处理消息失败', e)); for (const msg of msgList.filter(e => e.senderUin == this.core.selfInfo.uin)) { - if (msg.sendStatus == 2 && !msgIdSend.get(msg.msgId)) { + if (msg.sendStatus == SendStatusType.KSEND_STATUS_SUCCESS && !msgIdSend.get(msg.msgId)) { msgIdSend.put(msg.msgId, true); // 完成后再post OB11Constructor.message(this.core, this, msg)