fix: get_group_msg_history on qq version < 22106

This commit is contained in:
linyuchen
2024-03-21 18:10:01 +08:00
parent 5c34afc228
commit baf35d5496
4 changed files with 9 additions and 4 deletions

View File

@@ -8,3 +8,5 @@ type QQPkgInfo = {
} }
export const qqPkgInfo: QQPkgInfo = require(path.join(process.resourcesPath, "app/package.json")) export const qqPkgInfo: QQPkgInfo = require(path.join(process.resourcesPath, "app/package.json"))
export const isQQ998: boolean = qqPkgInfo.buildVersion >= "22106"

View File

@@ -5,6 +5,7 @@ import {selfInfo} from "../../common/data";
import {ReceiveCmdS, registerReceiveHook} from "../hook"; import {ReceiveCmdS, registerReceiveHook} from "../hook";
import {log} from "../../common/utils/log"; import {log} from "../../common/utils/log";
import {sleep} from "../../common/utils/helper"; import {sleep} from "../../common/utils/helper";
import {isQQ998} from "../../common/utils";
export let sendMessagePool: Record<string, ((sendSuccessMsg: RawMessage) => void) | null> = {}// peerUid: callbackFunnc export let sendMessagePool: Record<string, ((sendSuccessMsg: RawMessage) => void) | null> = {}// peerUid: callbackFunnc
@@ -25,7 +26,7 @@ export class NTQQMsgApi {
} }
static async getMsgHistory(peer: Peer, msgId: string, count: number) { static async getMsgHistory(peer: Peer, msgId: string, count: number) {
return await callNTQQApi<GeneralCallResult & {msgList: RawMessage[]}>({ return await callNTQQApi<GeneralCallResult & {msgList: RawMessage[]}>({
methodName: NTQQApiMethod.HISTORY_MSG, methodName: isQQ998 ? NTQQApiMethod.HISTORY_MSG_998 : NTQQApiMethod.HISTORY_MSG,
args: [{ args: [{
peer, peer,
msgId, msgId,

View File

@@ -23,7 +23,8 @@ export enum NTQQApiClass {
export enum NTQQApiMethod { export enum NTQQApiMethod {
RECENT_CONTACT = "nodeIKernelRecentContactService/fetchAndSubscribeABatchOfRecentContact", RECENT_CONTACT = "nodeIKernelRecentContactService/fetchAndSubscribeABatchOfRecentContact",
ADD_ACTIVE_CHAT = "nodeIKernelMsgService/getAioFirstViewLatestMsgsAndAddActiveChat", // 激活群助手内的聊天窗口,这样才能收到消息 ADD_ACTIVE_CHAT = "nodeIKernelMsgService/getAioFirstViewLatestMsgsAndAddActiveChat", // 激活群助手内的聊天窗口,这样才能收到消息
HISTORY_MSG = "nodeIKernelMsgService/getMsgsIncludeSelfAndAddActiveChat", HISTORY_MSG_998 = "nodeIKernelMsgService/getMsgsIncludeSelfAndAddActiveChat",
HISTORY_MSG = "nodeIKernelMsgService/getMsgsIncludeSelf",
LIKE_FRIEND = "nodeIKernelProfileLikeService/setBuddyProfileLike", LIKE_FRIEND = "nodeIKernelProfileLikeService/setBuddyProfileLike",
SELF_INFO = "fetchAuthData", SELF_INFO = "fetchAuthData",
FRIENDS = "nodeIKernelBuddyService/getBuddyList", FRIENDS = "nodeIKernelBuddyService/getBuddyList",

View File

@@ -11,7 +11,8 @@ import {log} from "../../../common/utils";
interface Payload { interface Payload {
group_id: number group_id: number
message_seq: number message_seq: number,
count: number
} }
export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, OB11Message[]> { export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, OB11Message[]> {
@@ -24,7 +25,7 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, OB11
} }
const startMsgId = (await dbUtil.getMsgByShortId(payload.message_seq))?.msgId || "0" const startMsgId = (await dbUtil.getMsgByShortId(payload.message_seq))?.msgId || "0"
// log("startMsgId", startMsgId) // log("startMsgId", startMsgId)
let msgList = (await NTQQMsgApi.getMsgHistory({chatType: ChatType.group, peerUid: group.groupCode}, startMsgId, 20)).msgList let msgList = (await NTQQMsgApi.getMsgHistory({chatType: ChatType.group, peerUid: group.groupCode}, startMsgId, parseInt(payload.count.toString()) || 0)).msgList
await Promise.all(msgList.map(async msg => { await Promise.all(msgList.map(async msg => {
msg.msgShortId = await dbUtil.addMsg(msg) msg.msgShortId = await dbUtil.addMsg(msg)
})) }))