mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
optimize
This commit is contained in:
@@ -137,21 +137,21 @@ export function invoke<
|
||||
S extends keyof NTService = any,
|
||||
M extends keyof NTService[S] & string = any,
|
||||
O = string
|
||||
>(method: `${O extends `${S}/${M}` ? `${S}/${M}` : string}`, args?: unknown[], options?: InvokeOptions<R>) {
|
||||
const className = options?.className ?? NTClass.NT_API
|
||||
const channel = options?.channel ?? NTChannel.IPC_UP_2
|
||||
const timeout = options?.timeout ?? 5000
|
||||
const afterFirstCmd = options?.afterFirstCmd ?? true
|
||||
>(method: `${O extends `${S}/${M}` ? `${S}/${M}` : string}`, args?: unknown[], options: InvokeOptions<R> = {}) {
|
||||
const className = options.className ?? NTClass.NT_API
|
||||
const channel = options.channel ?? NTChannel.IPC_UP_2
|
||||
const timeout = options.timeout ?? 5000
|
||||
const afterFirstCmd = options.afterFirstCmd ?? true
|
||||
const uuid = randomUUID()
|
||||
let eventName = className + '-' + channel[channel.length - 1]
|
||||
if (options?.classNameIsRegister) {
|
||||
if (options.classNameIsRegister) {
|
||||
eventName += '-register'
|
||||
}
|
||||
const apiArgs = [method, ...(args ?? [])]
|
||||
//log('callNTQQApi', channel, eventName, apiArgs, uuid)
|
||||
return new Promise((resolve: (data: R) => void, reject) => {
|
||||
let success = false
|
||||
if (!options?.cbCmd) {
|
||||
if (!options.cbCmd) {
|
||||
// QQ后端会返回结果,并且可以根据uuid识别
|
||||
hookApiCallbacks[uuid] = (r: R) => {
|
||||
success = true
|
||||
|
Reference in New Issue
Block a user