From 4678253815759b4a4101c7abc4e01bae504f2b3b Mon Sep 17 00:00:00 2001 From: idranme Date: Sun, 11 Aug 2024 00:18:54 +0800 Subject: [PATCH] sync --- src/common/utils/index.ts | 3 +- src/ntqqapi/api/msg.ts | 60 +++++++++++---------------------------- src/ntqqapi/api/user.ts | 52 +++++++++++++-------------------- 3 files changed, 37 insertions(+), 78 deletions(-) diff --git a/src/common/utils/index.ts b/src/common/utils/index.ts index fa95572..fd55490 100644 --- a/src/common/utils/index.ts +++ b/src/common/utils/index.ts @@ -15,5 +15,4 @@ if (!fs.existsSync(TEMP_DIR)) { } export { getVideoInfo } from './video' export { checkFfmpeg } from './video' -export { encodeSilk } from './audio' -export { isQQ998 } from './QQBasicInfo' \ No newline at end of file +export { encodeSilk } from './audio' \ No newline at end of file diff --git a/src/ntqqapi/api/msg.ts b/src/ntqqapi/api/msg.ts index f01de90..5603453 100644 --- a/src/ntqqapi/api/msg.ts +++ b/src/ntqqapi/api/msg.ts @@ -5,7 +5,7 @@ import { selfInfo } from '../../common/data' import { ReceiveCmdS, registerReceiveHook } from '../hook' import { log } from '../../common/utils/log' import { sleep } from '../../common/utils/helper' -import { isQQ998, getBuildVersion } from '../../common/utils' +import { getBuildVersion } from '../../common/utils' import { getSession } from '@/ntqqapi/wrapper' import { NTEventDispatch } from '@/common/utils/EventTask' @@ -72,25 +72,6 @@ export class NTQQMsgApi { return session?.getMsgService().getTempChatInfo(chatType, peerUid)! } - static enterOrExitAIO(peer: Peer, enter: boolean) { - return callNTQQApi({ - methodName: NTQQApiMethod.ENTER_OR_EXIT_AIO, - args: [ - { - "info_list": [ - { - peer, - "option": enter ? 1 : 2 - } - ] - }, - { - "send": true - }, - ], - }) - } - static async setEmojiLike(peer: Peer, msgSeq: string, emojiId: string, set: boolean = true) { // nt_qq//global//nt_data//Emoji//emoji-resource//sysface_res/apng/ 下可以看到所有QQ表情预览 // nt_qq\global\nt_data\Emoji\emoji-resource\face_config.json 里面有所有表情的id, 自带表情id是QSid, 标准emoji表情id是QCid @@ -158,20 +139,18 @@ export class NTQQMsgApi { }) } - static async getMsgHistory(peer: Peer, msgId: string, count: number) { + static async getMsgsByMsgId(peer: Peer | undefined, msgIds: string[] | undefined) { + if (!peer) throw new Error('peer is not allowed') + if (!msgIds) throw new Error('msgIds is not allowed') + const session = getSession() + //Mlikiowa: 参数不合规会导致NC异常崩溃 原因是TX未对进入参数判断 对应Android标记@NotNull AndroidJADX分析可得 + return await session?.getMsgService().getMsgsByMsgId(peer, msgIds)! + } + + static async getMsgHistory(peer: Peer, msgId: string, count: number, isReverseOrder: boolean = false) { + const session = getSession() // 消息时间从旧到新 - return await callNTQQApi({ - methodName: isQQ998 ? NTQQApiMethod.ACTIVE_CHAT_HISTORY : NTQQApiMethod.HISTORY_MSG, - args: [ - { - peer, - msgId, - cnt: count, - queryOrder: true, - }, - null, - ], - }) + return session?.getMsgService().getMsgsIncludeSelf(peer, msgId, count, isReverseOrder)! } static async fetchRecentContact() { @@ -196,16 +175,11 @@ export class NTQQMsgApi { } static async recallMsg(peer: Peer, msgIds: string[]) { - return await callNTQQApi({ - methodName: NTQQApiMethod.RECALL_MSG, - args: [ - { - peer, - msgIds, - }, - null, - ], - }) + const session = getSession() + return await session?.getMsgService().recallMsg({ + chatType: peer.chatType, + peerUid: peer.peerUid + }, msgIds) } static async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) { diff --git a/src/ntqqapi/api/user.ts b/src/ntqqapi/api/user.ts index bdc0f3b..37a1e4d 100644 --- a/src/ntqqapi/api/user.ts +++ b/src/ntqqapi/api/user.ts @@ -2,7 +2,7 @@ import { callNTQQApi, GeneralCallResult, NTQQApiClass, NTQQApiMethod } from '../ import { SelfInfo, User, UserDetailInfoByUin, UserDetailInfoByUinV2 } from '../types' import { ReceiveCmdS } from '../hook' import { selfInfo, friends, groupMembers } from '@/common/data' -import { CacheClassFuncAsync, isQQ998, log, sleep, getBuildVersion } from '@/common/utils' +import { CacheClassFuncAsync, log, getBuildVersion } from '@/common/utils' import { getSession } from '@/ntqqapi/wrapper' import { RequestUtil } from '@/common/utils/request' import { NodeIKernelProfileService, UserDetailSource, ProfileBizType } from '../services' @@ -85,39 +85,25 @@ export class NTQQUserApi { if (getBuildVersion() >= 26702) { return this.fetchUserDetailInfo(uid) } - // this.getUserInfo(uid) - let methodName = !isQQ998 ? NTQQApiMethod.USER_DETAIL_INFO : NTQQApiMethod.USER_DETAIL_INFO_WITH_BIZ_INFO - if (!withBizInfo) { - methodName = NTQQApiMethod.USER_DETAIL_INFO - } - const fetchInfo = async () => { - const result = await callNTQQApi<{ info: User }>({ - methodName, - cbCmd: ReceiveCmdS.USER_DETAIL_INFO, - afterFirstCmd: false, - cmdCB: (payload) => { - const success = payload.info.uid == uid - // log("get user detail info", success, uid, payload) - return success + type EventService = NodeIKernelProfileService['getUserDetailInfoWithBizInfo'] + type EventListener = NodeIKernelProfileListener['onProfileDetailInfoChanged'] + const [_retData, profile] = await NTEventDispatch.CallNormalEvent + + ( + 'NodeIKernelProfileService/getUserDetailInfoWithBizInfo', + 'NodeIKernelProfileListener/onProfileDetailInfoChanged', + 2, + 5000, + (profile: User) => { + if (profile.uid === uid) { + return true + } + return false }, - args: [ - { - uid, - }, - null, - ], - }) - const info = result.info - return info - } - // 首次请求两次才能拿到的等级信息 - if (!userInfoCache[uid] && getLevel) { - await fetchInfo() - await sleep(1000) - } - const userInfo = await fetchInfo() - userInfoCache[uid] = userInfo - return userInfo + uid, + [0] + ) + return profile } // return 'p_uin=o0xxx; p_skey=orXDssiGF8axxxxxxxxxxxxxx_; skey='