mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +00:00
feat: 拉取重启消息
This commit is contained in:
parent
186668c075
commit
781c107d8c
@ -9,6 +9,9 @@ class LimitedHashTable<K, V> {
|
||||
constructor(maxSize: number) {
|
||||
this.maxSize = maxSize;
|
||||
}
|
||||
resize(count: number) {
|
||||
this.maxSize = count;
|
||||
}
|
||||
|
||||
set(key: K, value: V): void {
|
||||
const isExist = this.keyToValue.get(key);
|
||||
@ -19,6 +22,8 @@ class LimitedHashTable<K, V> {
|
||||
this.valueToKey.set(value, key);
|
||||
while (this.keyToValue.size !== this.valueToKey.size) {
|
||||
console.log('keyToValue.size !== valueToKey.size Error Atom');
|
||||
this.keyToValue.clear();
|
||||
this.valueToKey.clear();
|
||||
}
|
||||
// console.log('---------------');
|
||||
// console.log(this.keyToValue);
|
||||
@ -71,7 +76,7 @@ class MessageUniqueWrapper {
|
||||
const shortId = parseInt(hash.digest('hex').slice(0, 8), 16);
|
||||
const isExist = this.msgIdMap.getKey(shortId);
|
||||
if (isExist && isExist === msgId) {
|
||||
return undefined;
|
||||
return shortId;
|
||||
}
|
||||
this.msgIdMap.set(msgId, shortId);
|
||||
this.msgDataMap.set(key, shortId);
|
||||
@ -100,6 +105,10 @@ class MessageUniqueWrapper {
|
||||
if (!shortId) return undefined;
|
||||
return this.getMsgIdAndPeerByShortId(shortId);
|
||||
}
|
||||
resize(maxSize: number): void {
|
||||
this.msgIdMap.resize(maxSize);
|
||||
this.msgDataMap.resize(maxSize);
|
||||
}
|
||||
}
|
||||
|
||||
export const MessageUnique = new MessageUniqueWrapper(1000);
|
||||
export const MessageUnique: MessageUniqueWrapper = new MessageUniqueWrapper();
|
@ -1,13 +1,38 @@
|
||||
import { GetFileListParam, Peer, RawMessage, SendMessageElement } from '@/core/entities';
|
||||
import { selfInfo } from '@/core/data';
|
||||
import { log, logError } from '@/common/utils/log';
|
||||
import { ChatType, GetFileListParam, Peer, RawMessage, SendMessageElement } from '@/core/entities';
|
||||
import { friends, groups, selfInfo } from '@/core/data';
|
||||
import { log, logError, logWarn } from '@/common/utils/log';
|
||||
import { sleep } from '@/common/utils/helper';
|
||||
import { napCatCore } from '@/core';
|
||||
import { napCatCore, NTQQUserApi } from '@/core';
|
||||
import { MsgListener, onGroupFileInfoUpdateParamType } from '@/core/listeners';
|
||||
import { GeneralCallResult } from '@/core/services/common';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { MessageUnique } from '../../../common/utils/MessageUnique';
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
napCatCore.onLoginSuccess(() => {
|
||||
setTimeout(async () => {
|
||||
if (groups.size > 100) {
|
||||
logWarn('群数量大于100,可能会导致性能问题');
|
||||
}
|
||||
let predict = (groups.size + friends.size) / 5;
|
||||
predict = predict < 20 ? 20 : predict;
|
||||
predict = predict > 50 ? 50 : predict;
|
||||
//let waitpromise: Array<Promise<{ msgList: RawMessage[]; }>> = [];
|
||||
MessageUnique.resize(predict * 50);
|
||||
let RecentContact = await NTQQUserApi.getRecentContactListSnapShot(predict);
|
||||
if (RecentContact?.info?.changedList && RecentContact?.info?.changedList?.length > 0) {
|
||||
for (let i = 0; i < RecentContact.info.changedList.length; i++) {
|
||||
let Peer: Peer = { chatType: RecentContact.info.changedList[i].chatType, peerUid: RecentContact.info.changedList[i].peerUid, guildId: '' };
|
||||
let msgList = await NTQQMsgApi.getMsgHistory(Peer, RecentContact.info.changedList[i].msgId, 50);
|
||||
for (let j = 0; j < msgList.msgList.length; j++) {
|
||||
let shortId = MessageUnique.createMsg(Peer, msgList.msgList[j].msgId);
|
||||
//console.log(`开始创建 ${shortId}<------>${msgList.msgList[j].msgId}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
}, 100);
|
||||
const sendMessagePool: Record<string, ((sendSuccessMsg: RawMessage) => void | Promise<void>) | null> = {};// peerUid: callbackFunc
|
||||
|
||||
const sendSuccessCBMap: Record<string, ((sendSuccessMsg: RawMessage) => boolean | Promise<boolean>) | null> = {};// uuid: callbackFunc
|
||||
@ -71,13 +96,13 @@ setTimeout(() => {
|
||||
|
||||
export class NTQQMsgApi {
|
||||
// static napCatCore: NapCatCore | null = null;
|
||||
// enum BaseEmojiType {
|
||||
// NORMAL_EMOJI,
|
||||
// SUPER_EMOJI,
|
||||
// RANDOM_SUPER_EMOJI,
|
||||
// CHAIN_SUPER_EMOJI,
|
||||
// EMOJI_EMOJI
|
||||
// }
|
||||
// enum BaseEmojiType {
|
||||
// NORMAL_EMOJI,
|
||||
// SUPER_EMOJI,
|
||||
// RANDOM_SUPER_EMOJI,
|
||||
// CHAIN_SUPER_EMOJI,
|
||||
// EMOJI_EMOJI
|
||||
// }
|
||||
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
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Peer } from "../entities";
|
||||
import { NodeIKernelRecentContactListener } from "../listeners/NodeIKernelRecentContactListener";
|
||||
import { GeneralCallResult } from "./common";
|
||||
export interface FSABRecentContactParams {
|
||||
anchorPointContact: {
|
||||
contactId: string;
|
||||
@ -33,7 +34,14 @@ export interface NodeIKernelRecentContactService {
|
||||
|
||||
enterOrExitMsgList(...args: unknown[]): unknown; // 1 arguments
|
||||
|
||||
/*!---!*/getRecentContactListSnapShot(count: number): unknown; // 1 arguments
|
||||
/*!---!*/getRecentContactListSnapShot(count: number): Promise<GeneralCallResult & {
|
||||
info: {
|
||||
errCode: number,
|
||||
errMsg: string,
|
||||
sortedContactList: Array<number>,
|
||||
changedList: Array<any>
|
||||
}
|
||||
}>; // 1 arguments
|
||||
|
||||
clearMsgUnreadCount(...args: unknown[]): unknown; // 1 arguments
|
||||
|
||||
|
@ -136,26 +136,26 @@ export class OB11Constructor {
|
||||
message_data['type'] = 'reply';
|
||||
// log("收到回复消息", element.replyElement.replayMsgSeq)
|
||||
try {
|
||||
// let retData = await NTQQMsgApi.getMsgsBySeqAndCount(
|
||||
// {
|
||||
// chatType: msg.chatType,
|
||||
// peerUid: msg.peerUid,
|
||||
// guildId: '',
|
||||
// },
|
||||
// element.replyElement.replayMsgSeq,
|
||||
// 1,
|
||||
// false,
|
||||
// true
|
||||
// );
|
||||
let replyMsg = await NTQQMsgApi.getMsgsBySeqAndCount(
|
||||
{
|
||||
chatType: msg.chatType,
|
||||
peerUid: msg.peerUid,
|
||||
guildId: '',
|
||||
},
|
||||
element.replyElement.replayMsgSeq,
|
||||
1,
|
||||
true,
|
||||
true
|
||||
);
|
||||
// console.log(JSON.stringify(retData, null, 2));
|
||||
const replyMsg = await NTQQMsgApi.getMsgsBySeqAndCount({ peerUid: msg.peerUid, guildId: '', chatType: msg.chatType }, element.replyElement.replayMsgSeq, 1, true, true);
|
||||
// log("找到回复消息", replyMsg.msgShortId, replyMsg.msgId)
|
||||
// const replyMsg = await NTQQMsgApi.getMsgsBySeqAndCount({ peerUid: msg.peerUid, guildId: '', chatType: msg.chatType }, element.replyElement.replayMsgSeq, 1, true, true);
|
||||
if (replyMsg) {
|
||||
message_data['data']['id'] = MessageUnique.createMsg({ peerUid: msg.peerUid, guildId: '', chatType: msg.chatType }, replyMsg.msgList[0].msgId);
|
||||
message_data['data']['id'] = MessageUnique.createMsg({ peerUid: msg.peerUid, guildId: '', chatType: msg.chatType }, replyMsg.msgList[0].msgId)?.toString();
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
//log("找到回复消息", message_data['data']['id'], replyMsg.msgList[0].msgId)
|
||||
} catch (e: any) {
|
||||
logError('获取不到引用的消息', e.stack, element.replyElement.replayMsgSeq);
|
||||
}
|
||||
@ -202,18 +202,18 @@ export class OB11Constructor {
|
||||
message_data['data']['file_id'] = videoOrFileElement.fileUuid;
|
||||
message_data['data']['file_size'] = videoOrFileElement.fileSize;
|
||||
if (!element.videoElement) {
|
||||
// dbUtil.addFileCache({
|
||||
// msgId: msg.msgId,
|
||||
// name: videoOrFileElement.fileName,
|
||||
// path: videoOrFileElement.filePath,
|
||||
// size: parseInt(videoOrFileElement.fileSize || '0'),
|
||||
// uuid: videoOrFileElement.fileUuid || '',
|
||||
// url: '',
|
||||
// element: element.videoElement || element.fileElement,
|
||||
// elementType: element.videoElement ? ElementType.VIDEO : ElementType.FILE,
|
||||
// elementId: element.elementId
|
||||
// }).then();
|
||||
// }
|
||||
// dbUtil.addFileCache({
|
||||
// msgId: msg.msgId,
|
||||
// name: videoOrFileElement.fileName,
|
||||
// path: videoOrFileElement.filePath,
|
||||
// size: parseInt(videoOrFileElement.fileSize || '0'),
|
||||
// uuid: videoOrFileElement.fileUuid || '',
|
||||
// url: '',
|
||||
// element: element.videoElement || element.fileElement,
|
||||
// elementType: element.videoElement ? ElementType.VIDEO : ElementType.FILE,
|
||||
// elementId: element.elementId
|
||||
// }).then();
|
||||
// }
|
||||
}
|
||||
}
|
||||
else if (element.pttElement) {
|
||||
@ -285,6 +285,7 @@ export class OB11Constructor {
|
||||
else (resMsg.message as OB11MessageData[]).push(message_data);
|
||||
resMsg.raw_message += cqCode;
|
||||
}
|
||||
|
||||
}
|
||||
resMsg.raw_message = resMsg.raw_message.trim();
|
||||
return resMsg;
|
||||
|
Loading…
Reference in New Issue
Block a user