refactor: member qq_level

This commit is contained in:
linyuchen
2024-03-17 15:33:56 +08:00
parent 60e0c9e4ba
commit af8cf1882c
17 changed files with 122 additions and 32 deletions

View File

@@ -15,7 +15,9 @@ export interface Peer {
export class NTQQMsgApi {
static async activateGroupChat(groupCode: string) {
return await callNTQQApi({
// await this.fetchRecentContact();
// await sleep(500);
return await callNTQQApi<GeneralCallResult>({
methodName: NTQQApiMethod.ADD_ACTIVE_CHAT,
args: [{peer:{peerUid: groupCode, chatType: ChatType.group}, cnt: 20}]
})

View File

@@ -59,7 +59,7 @@ export class SendMsgElementConstructor {
}
}
static async pic(picPath: string): Promise<SendPicElement> {
static async pic(picPath: string, summary: string = ""): Promise<SendPicElement> {
const {md5, fileName, path, fileSize} = await NTQQFileApi.uploadFile(picPath, ElementType.PIC);
if (fileSize === 0) {
throw "文件异常大小为0";
@@ -78,7 +78,7 @@ export class SendMsgElementConstructor {
fileUuid: "",
fileSubId: "",
thumbFileSize: 0,
summary: "",
summary,
};
return {
@@ -136,7 +136,7 @@ export class SendMsgElementConstructor {
folder: thumb,
size: videoInfo.width + "x" + videoInfo.height
}).on("end", () => {
resolve(pathLib.join(thumb, thumbFileName));
resolve(pathLib.join(thumb, thumbFileName));
});
})
let thumbPath = new Map()

28
src/ntqqapi/external/ccpoke/index.ts vendored Normal file
View File

@@ -0,0 +1,28 @@
import {log} from "../../../common/utils";
let pokeEngine: any = null
type PokeHandler = (id: string, isGroup: boolean)=>void
let pokeRecords: Record<string, number> = {}
export function registerPokeHandler(handler: PokeHandler){
if(!pokeEngine){
try {
pokeEngine = require("./ccpoke/poke-win32-x64.node")
pokeEngine.performHooks();
}catch (e) {
log("戳一戳引擎加载失败", e)
return
}
}
pokeEngine.setHandlerForPokeHook((id: string, isGroup: boolean)=>{
let existTime = pokeRecords[id]
if (existTime){
if (Date.now() - existTime < 1500){
return
}
}
pokeRecords[id] = Date.now()
handler(id, isGroup);
})
}

Binary file not shown.

View File

@@ -144,10 +144,20 @@ export function removeReceiveHook(id: string) {
receiveHooks.splice(index, 1);
}
let activatedGroups: string[] = [];
async function updateGroups(_groups: Group[], needUpdate: boolean = true) {
for (let group of _groups) {
log("update group", group)
NTQQMsgApi.activateGroupChat(group.groupCode).then()
// log("update group", group)
if (!activatedGroups.includes(group.groupCode)) {
NTQQMsgApi.activateGroupChat(group.groupCode).then((r) => {
activatedGroups.push(group.groupCode);
// log(`激活群聊天窗口${group.groupName}(${group.groupCode})`, r)
// if (r.result !== 0) {
// setTimeout(() => NTQQMsgApi.activateGroupChat(group.groupCode).then(r => log(`再次激活群聊天窗口${group.groupName}(${group.groupCode})`, r)), 500);
// }else {
// }
}).catch(log)
}
let existGroup = groups.find(g => g.groupCode == group.groupCode);
if (existGroup) {
Object.assign(existGroup, group);

View File

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