mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix: get_group_msg_history on qq version < 22106
This commit is contained in:
@@ -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"
|
@@ -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,
|
||||||
|
@@ -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",
|
||||||
|
@@ -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)
|
||||||
}))
|
}))
|
||||||
|
Reference in New Issue
Block a user