mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
optimize
This commit is contained in:
parent
c8e897abdb
commit
d3abaf806f
@ -45,8 +45,11 @@ export class NTQQGroupApi extends Service {
|
||||
return result.groupList
|
||||
}
|
||||
|
||||
async getGroupMembers(groupCode: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||
const sceneId = await invoke(NTMethod.GROUP_MEMBER_SCENE, [{ groupCode, scene: 'groupMemberList_MainWindow' }])
|
||||
async getGroupMembers(groupCode: string, num = 3000) {
|
||||
const sceneId = await invoke(NTMethod.GROUP_MEMBER_SCENE, [{
|
||||
groupCode,
|
||||
scene: 'groupMemberList_MainWindow'
|
||||
}])
|
||||
const data = await invoke(NTMethod.GROUP_MEMBERS, [{ sceneId, num }])
|
||||
if (data.errCode !== 0) {
|
||||
throw new Error('获取群成员列表出错,' + data.errMsg)
|
||||
|
@ -118,7 +118,7 @@ export class NTQQUserApi extends Service {
|
||||
await this.ctx.sleep(30)
|
||||
member = await this.ctx.ntGroupApi.searchMember(groupCode, uin)
|
||||
}
|
||||
uid = member.values().find(e => e.uin === uin)?.uid
|
||||
uid = Array.from(member.values()).find(e => e.uin === uin)?.uid
|
||||
}
|
||||
if (!uid) {
|
||||
const unveifyUid = (await this.getUserDetailInfoByUin(uin)).info.uid
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { Context } from 'cordis'
|
||||
import { Dict } from 'cosmokit'
|
||||
import { getBuildVersion } from '@/common/utils/misc'
|
||||
// @ts-expect-error: Unreachable code error
|
||||
import addon from './external/crychic-win32-x64.node?asset'
|
||||
|
||||
export class Native {
|
||||
@ -35,7 +34,7 @@ export class Native {
|
||||
}
|
||||
try {
|
||||
this.crychic = require(addon)
|
||||
this.crychic.init()
|
||||
this.crychic!.init()
|
||||
} catch (e) {
|
||||
this.ctx.logger.warn('crychic 加载失败', e)
|
||||
}
|
||||
|
@ -124,7 +124,12 @@ export function invoke<
|
||||
return new Promise<R>((resolve, reject) => {
|
||||
const apiArgs = [method, ...args]
|
||||
const callbackId = randomUUID()
|
||||
let eventId: string
|
||||
|
||||
const timeoutId = setTimeout(() => {
|
||||
if (eventId) {
|
||||
removeReceiveHook(eventId)
|
||||
}
|
||||
log(`ntqq api timeout ${channel}, ${eventName}, ${method}`, args)
|
||||
reject(`ntqq api timeout ${channel}, ${eventName}, ${method}, ${JSON.stringify(args)}`)
|
||||
}, timeout)
|
||||
@ -140,16 +145,16 @@ export function invoke<
|
||||
let result: unknown
|
||||
// 这里的callback比较特殊,QQ后端先返回是否调用成功,再返回一条结果数据
|
||||
const secondCallback = () => {
|
||||
const hookId = registerReceiveHook<R>(options.cbCmd!, (payload) => {
|
||||
eventId = registerReceiveHook<R>(options.cbCmd!, (payload) => {
|
||||
if (options.cmdCB) {
|
||||
if (options.cmdCB(payload, result)) {
|
||||
removeReceiveHook(hookId)
|
||||
removeReceiveHook(eventId)
|
||||
clearTimeout(timeoutId)
|
||||
resolve(payload)
|
||||
}
|
||||
}
|
||||
else {
|
||||
removeReceiveHook(hookId)
|
||||
removeReceiveHook(eventId)
|
||||
clearTimeout(timeoutId)
|
||||
resolve(payload)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"target": "ES2023",
|
||||
"module": "CommonJS",
|
||||
"outDir": "./dist",
|
||||
"strict": true,
|
||||
@ -20,7 +20,10 @@
|
||||
"./src/ntqqapi/*"
|
||||
]
|
||||
},
|
||||
"noEmit": true
|
||||
"noEmit": true,
|
||||
"types": [
|
||||
"electron-vite/node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
|
Loading…
x
Reference in New Issue
Block a user