From 26609bb8fd64fc2553313fbd85a575975995ce48 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: Sat, 3 Aug 2024 13:11:25 +0800 Subject: [PATCH] =?UTF-8?q?chore:=209.9.15=E5=85=BC=E5=AE=B9sendmsg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/utils/QQBasicInfo.ts | 7 ++++--- src/core/src/apis/msg.ts | 19 ++++++++----------- .../src/services/NodeIKernelMsgService.ts | 5 ++++- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/common/utils/QQBasicInfo.ts b/src/common/utils/QQBasicInfo.ts index bbf08c60..3f921859 100644 --- a/src/common/utils/QQBasicInfo.ts +++ b/src/common/utils/QQBasicInfo.ts @@ -3,7 +3,6 @@ import fs from 'node:fs'; import os from 'node:os'; import { systemPlatform } from '@/common/utils/system'; import { logError } from '@/common/utils/log'; - export const exePath = process.execPath; export const pkgInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'package.json'); @@ -47,7 +46,7 @@ let _qqVersionConfigInfo: QQVersionConfigInfo = { if (fs.existsSync(configVersionInfoPath)) { try { - const _ =JSON.parse(fs.readFileSync(configVersionInfoPath).toString()); + const _ = JSON.parse(fs.readFileSync(configVersionInfoPath).toString()); _qqVersionConfigInfo = Object.assign(_qqVersionConfigInfo, _); } catch (e) { logError('Load QQ version config info failed, Use default version', e); @@ -68,7 +67,9 @@ export const qqPkgInfo: QQPkgInfo = JSON.parse(fs.readFileSync(pkgInfoPath).toSt // Linux // app_version: '3.2.9-25765', // qua: 'V1_LNX_NQ_3.2.10_25765_GW_B', - +export function requireMinNTQBuild(buildStr: string) { + return parseInt(qqVersionConfigInfo.buildId) >= parseInt(buildStr); +} let _appid: string = '537237765'; // 默认为 Windows 平台的 appid if (systemPlatform === 'linux') { _appid = '537234773'; diff --git a/src/core/src/apis/msg.ts b/src/core/src/apis/msg.ts index 30f32eea..4a041399 100644 --- a/src/core/src/apis/msg.ts +++ b/src/core/src/apis/msg.ts @@ -1,4 +1,4 @@ -import { ElementType, GetFileListParam, MessageElement, Peer, RawMessage, SendMessageElement, SendMsgElementConstructor } from '@/core/entities'; +import { ChatType, ElementType, GetFileListParam, MessageElement, Peer, RawMessage, SendMessageElement, SendMsgElementConstructor } from '@/core/entities'; import { friends, groups, selfInfo } from '@/core/data'; import { log, logError, logWarn } from '@/common/utils/log'; import { sleep } from '@/common/utils/helper'; @@ -7,6 +7,7 @@ import { NodeIKernelMsgListener, onGroupFileInfoUpdateParamType } from '@/core/l import { GeneralCallResult } from '@/core/services/common'; import { MessageUnique } from '../../../common/utils/MessageUnique'; import { NTEventDispatch } from '@/common/utils/EventTask'; +import { requireMinNTQBuild } from '@/common/utils/QQBasicInfo'; async function LoadMessageIdList(Peer: Peer, msgId: string) { let msgList = await NTQQMsgApi.getMsgHistory(Peer, msgId, 50); @@ -192,7 +193,7 @@ export class NTQQMsgApi { // return msgId; // } - let msgId = await NTQQMsgApi.getMsgUnique(await NTQQMsgApi.getServerTime()); + let msgId = await NTQQMsgApi.getMsgUnique(peer.chatType, await NTQQMsgApi.getServerTime()); let data = await NTEventDispatch.CallNormalEvent< (msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map) => Promise, (msgList: RawMessage[]) => void @@ -226,7 +227,7 @@ export class NTQQMsgApi { } static async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) { //唉? !我有个想法 - let msgId = await NTQQMsgApi.getMsgUnique(await NTQQMsgApi.getServerTime()); + let msgId = await NTQQMsgApi.getMsgUnique(peer.chatType, await NTQQMsgApi.getServerTime()); peer.guildId = msgId; let data = await NTEventDispatch.CallNormalEvent< (msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map) => Promise, @@ -256,16 +257,12 @@ export class NTQQMsgApi { }); return retMsg; } - static async getMsgUniqueEx() { - let msgId = await NTQQMsgApi.getMsgUnique(await NTQQMsgApi.getServerTime()); - return msgId; - } - static async getMsgUnique(time: string) { + static async getMsgUnique(chatType: number, time: string) { + if (requireMinNTQBuild('26702')) { + return napCatCore.session.getMsgService().generateMsgUniqueId(chatType, time); + } return napCatCore.session.getMsgService().getMsgUniqueId(time); } - static async getMsgUniqueByTimeV2() { - return NTEventDispatch.CallNoListenerEvent('NodeIKernelMsgService/getMsgUniqueId', 5000, await NTQQMsgApi.getServerTimeV2()) - } static async getServerTime() { return napCatCore.session.getMSFService().getServerTime(); } diff --git a/src/core/src/services/NodeIKernelMsgService.ts b/src/core/src/services/NodeIKernelMsgService.ts index b7abbd42..f6063199 100644 --- a/src/core/src/services/NodeIKernelMsgService.ts +++ b/src/core/src/services/NodeIKernelMsgService.ts @@ -3,6 +3,9 @@ import { NodeIKernelMsgListener } from '@/core/listeners/NodeIKernelMsgListener' import { GeneralCallResult } from '@/core/services/common'; export interface NodeIKernelMsgService { + + generateMsgUniqueId(chatType: number, time: string): string; + addKernelMsgListener(nodeIKernelMsgListener: NodeIKernelMsgListener): number; sendMsg(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map): Promise; @@ -629,7 +632,7 @@ export interface NodeIKernelMsgService { prepareTempChat(args: unknown): unknown;//主动临时消息 不做 sendSsoCmdReqByContend(cmd: string, param: string): Promise; - + //chattype,uid->Promise getTempChatInfo(ChatType: number, Uid: string): unknown;