chore: 9.9.15兼容sendmsg

This commit is contained in:
手瓜一十雪 2024-08-03 13:11:25 +08:00
parent de3fa9aaa4
commit 26609bb8fd
3 changed files with 16 additions and 15 deletions

View File

@ -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';

View File

@ -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<any, any>) => Promise<unknown>,
(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<any, any>) => Promise<unknown>,
@ -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']>('NodeIKernelMsgService/getMsgUniqueId', 5000, await NTQQMsgApi.getServerTimeV2())
}
static async getServerTime() {
return napCatCore.session.getMSFService().getServerTime();
}

View File

@ -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<any, any>): Promise<GeneralCallResult>;
@ -629,7 +632,7 @@ export interface NodeIKernelMsgService {
prepareTempChat(args: unknown): unknown;//主动临时消息 不做
sendSsoCmdReqByContend(cmd: string, param: string): Promise<unknown>;
//chattype,uid->Promise<any>
getTempChatInfo(ChatType: number, Uid: string): unknown;