This commit is contained in:
idranme 2024-09-21 20:19:26 +08:00
parent 08e7e471d6
commit 0c456e2160
No known key found for this signature in database
GPG Key ID: 926F7B5B668E495F
6 changed files with 21 additions and 27 deletions

View File

@ -41,7 +41,7 @@
"electron-vite": "^2.3.0", "electron-vite": "^2.3.0",
"protobufjs-cli": "^1.1.3", "protobufjs-cli": "^1.1.3",
"typescript": "^5.6.2", "typescript": "^5.6.2",
"vite": "^5.4.6", "vite": "^5.4.7",
"vite-plugin-cp": "^4.0.8" "vite-plugin-cp": "^4.0.8"
}, },
"packageManager": "yarn@4.4.1" "packageManager": "yarn@4.4.1"

View File

@ -12,8 +12,9 @@ export function calcQQLevel(level: QQLevel) {
/** QQ Build Version */ /** QQ Build Version */
export function getBuildVersion(): number { export function getBuildVersion(): number {
const version: string = globalThis.LiteLoader.versions.qqnt //const version: string = globalThis.LiteLoader.versions.qqnt
return +version.split('-')[1] //return +version.split('-')[1]
return +globalThis.LiteLoader.package.qqnt.buildVersion
} }
/** 在保证老对象已有的属性不变化的情况下将新对象的属性复制到老对象 */ /** 在保证老对象已有的属性不变化的情况下将新对象的属性复制到老对象 */

View File

@ -50,7 +50,7 @@ export class NTQQMsgApi extends Service {
} }
async activateChat(peer: Peer) { async activateChat(peer: Peer) {
return await invoke<GeneralCallResult>(NTMethod.ACTIVE_CHAT_PREVIEW, [{ peer, cnt: 20 }, null]) return await invoke<GeneralCallResult>(NTMethod.ACTIVE_CHAT_PREVIEW, [{ peer, cnt: 1 }, null])
} }
async activateChatAndGetHistory(peer: Peer) { async activateChatAndGetHistory(peer: Peer) {

View File

@ -1,4 +1,4 @@
import fs from 'node:fs' import { unlink } from 'node:fs/promises'
import { Service, Context } from 'cordis' import { Service, Context } from 'cordis'
import { registerCallHook, registerReceiveHook, ReceiveCmdS } from './hook' import { registerCallHook, registerReceiveHook, ReceiveCmdS } from './hook'
import { Config as LLOBConfig } from '../common/types' import { Config as LLOBConfig } from '../common/types'
@ -13,7 +13,6 @@ import {
GroupMember, GroupMember,
CategoryFriend, CategoryFriend,
SimpleInfo, SimpleInfo,
User,
ChatType ChatType
} from './types' } from './types'
import { selfInfo } from '../common/globalVars' import { selfInfo } from '../common/globalVars'
@ -53,29 +52,24 @@ class Core extends Service {
private registerListener() { private registerListener() {
registerReceiveHook<{ registerReceiveHook<{
data: CategoryFriend[] data?: CategoryFriend[]
userSimpleInfos?: Map<string, SimpleInfo> //V2
buddyCategory?: CategoryFriend[] //V2
}>(ReceiveCmdS.FRIENDS, (payload) => { }>(ReceiveCmdS.FRIENDS, (payload) => {
type V2data = { userSimpleInfos: Map<string, SimpleInfo> } let uids: string[] = []
let friendList: User[] = [] if (payload.buddyCategory) {
if ('userSimpleInfos' in payload) { uids = payload.buddyCategory.flatMap(item => item.buddyUids)
friendList = Object.values((payload as unknown as V2data).userSimpleInfos).map((v: SimpleInfo) => { } else if (payload.data) {
return { uids = payload.data.flatMap(item => item.buddyList.map(e => e.uid))
...v.coreInfo,
} }
}) for (const uid of uids) {
} else { this.ctx.ntMsgApi.activateChat({ peerUid: uid, chatType: ChatType.friend })
for (const fData of payload.data) {
friendList.push(...fData.buddyList)
}
}
this.ctx.logger.info('好友列表变动', friendList.length)
for (const friend of friendList) {
this.ctx.ntMsgApi.activateChat({ peerUid: friend.uid, chatType: ChatType.friend })
} }
this.ctx.logger.info('好友列表变动', uids.length)
}) })
// 自动清理新消息文件 // 自动清理新消息文件
registerReceiveHook<{ msgList: Array<RawMessage> }>([ReceiveCmdS.NEW_MSG, ReceiveCmdS.NEW_ACTIVE_MSG], (payload) => { registerReceiveHook<{ msgList: RawMessage[] }>([ReceiveCmdS.NEW_MSG, ReceiveCmdS.NEW_ACTIVE_MSG], (payload) => {
if (!this.config.autoDeleteFile) { if (!this.config.autoDeleteFile) {
return return
} }
@ -94,9 +88,7 @@ class Core extends Service {
} }
for (const path of pathList) { for (const path of pathList) {
if (path) { if (path) {
fs.unlink(path, () => { unlink(path).then(() => this.ctx.logger.info('删除文件成功', path))
this.ctx.logger.info('删除文件成功', path)
})
} }
} }
}, this.config.autoDeleteFileSecond! * 1000) }, this.config.autoDeleteFileSecond! * 1000)

View File

@ -8,7 +8,7 @@ export enum BuddyListReqType {
export interface NodeIKernelBuddyService { export interface NodeIKernelBuddyService {
getBuddyListV2(callFrom: string, reqType: BuddyListReqType): Promise<GeneralCallResult & { getBuddyListV2(callFrom: string, reqType: BuddyListReqType): Promise<GeneralCallResult & {
data: { data: {
categoryId: number //9999疑似兜底数据 categoryId: number
categorySortId: number categorySortId: number
categroyName: string categroyName: string
categroyMbCount: number categroyMbCount: number

View File

@ -394,6 +394,7 @@ export namespace OB11Entities {
} }
} }
if (grayTipElement.xmlElement?.templId === '10229' || grayTipElement.jsonGrayTipElement?.busiId === '19324') { if (grayTipElement.xmlElement?.templId === '10229' || grayTipElement.jsonGrayTipElement?.busiId === '19324') {
ctx.logger.info('收到好友添加消息', msg.peerUid)
const uin = +msg.peerUin || +(await ctx.ntUserApi.getUinByUid(msg.peerUid)) const uin = +msg.peerUin || +(await ctx.ntUserApi.getUinByUid(msg.peerUid))
return new OB11FriendAddNoticeEvent(uin) return new OB11FriendAddNoticeEvent(uin)
} }