Merge pull request #502 from LLOneBot/dev

release: 4.1.4
This commit is contained in:
idranme 2024-11-09 22:29:16 +08:00 committed by GitHub
commit 0d27ef7ebc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 34 deletions

View File

@ -26,7 +26,7 @@
"cosmokit": "^1.6.3", "cosmokit": "^1.6.3",
"express": "^5.0.1", "express": "^5.0.1",
"fluent-ffmpeg": "^2.1.3", "fluent-ffmpeg": "^2.1.3",
"minato": "^3.6.0", "minato": "^3.6.1",
"protobufjs": "^7.4.0", "protobufjs": "^7.4.0",
"silk-wasm": "^3.6.3", "silk-wasm": "^3.6.3",
"ts-case-convert": "^2.1.0", "ts-case-convert": "^2.1.0",
@ -35,9 +35,9 @@
"devDependencies": { "devDependencies": {
"@types/cors": "^2.8.17", "@types/cors": "^2.8.17",
"@types/express": "^5.0.0", "@types/express": "^5.0.0",
"@types/fluent-ffmpeg": "^2.1.26", "@types/fluent-ffmpeg": "^2.1.27",
"@types/node": "^20.14.15", "@types/node": "^20.14.15",
"@types/ws": "^8.5.12", "@types/ws": "^8.5.13",
"electron": "^31.4.0", "electron": "^31.4.0",
"electron-vite": "^2.3.0", "electron-vite": "^2.3.0",
"protobufjs-cli": "^1.1.3", "protobufjs-cli": "^1.1.3",

View File

@ -35,7 +35,6 @@ import {
NTQQWindowApi NTQQWindowApi
} from '../ntqqapi/api' } from '../ntqqapi/api'
import { existsSync, mkdirSync } from 'node:fs' import { existsSync, mkdirSync } from 'node:fs'
import { checkChanelId } from '@/ntqqapi/ntcall'
declare module 'cordis' { declare module 'cordis' {
interface Events { interface Events {
@ -185,7 +184,6 @@ function onLoad() {
if (config.enableLLOB && (config.satori.enable || config.ob11.enable)) { if (config.enableLLOB && (config.satori.enable || config.ob11.enable)) {
startHook() startHook()
await checkChanelId()
await ctx.sleep(600) await ctx.sleep(600)
} else { } else {
llonebotError.otherError = 'LLOneBot 未启动' llonebotError.otherError = 'LLOneBot 未启动'

View File

@ -1,4 +1,4 @@
import { invoke, NTChannel, NTMethod } from './ntcall' import { NTMethod } from './ntcall'
import { log } from '@/common/utils' import { log } from '@/common/utils'
import { randomUUID } from 'node:crypto' import { randomUUID } from 'node:crypto'
import { ipcMain } from 'electron' import { ipcMain } from 'electron'
@ -40,7 +40,7 @@ const callHooks: Array<{
}> = [] }> = []
export function startHook() { export function startHook() {
log("start hook") log('start hook')
const senderExclude = Symbol() const senderExclude = Symbol()

View File

@ -1,6 +1,6 @@
import { ipcMain } from 'electron' import { ipcMain } from 'electron'
import { hookApiCallbacks, ReceiveCmdS, registerReceiveHook, removeReceiveHook } from './hook' import { hookApiCallbacks, registerReceiveHook, removeReceiveHook } from './hook'
import { getBuildVersion, log } from '../common/utils' import { log } from '../common/utils'
import { randomUUID } from 'node:crypto' import { randomUUID } from 'node:crypto'
import { import {
GeneralCallResult, GeneralCallResult,
@ -17,8 +17,6 @@ import {
NodeIKernelRobotService, NodeIKernelRobotService,
NodeIKernelNodeMiscService NodeIKernelNodeMiscService
} from './services' } from './services'
import { CategoryFriend, SimpleInfo, UserDetailInfoByUin } from '@/ntqqapi/types'
import { selfInfo } from '@/common/globalVars'
export enum NTClass { export enum NTClass {
NT_API = 'ns-ntApi', NT_API = 'ns-ntApi',
@ -110,38 +108,26 @@ interface InvokeOptions<ReturnType> {
timeout?: number timeout?: number
} }
let availableChannel: NTChannel | undefined = undefined; let channel: NTChannel
export async function checkChanelId(){ function getChannel() {
async function testChannel(channel: NTChannel) { if (channel) {
await invoke<UserDetailInfoByUin>( return channel
'nodeIKernelProfileService/getUserDetailInfoByUin', }
[{ uin: selfInfo.uin }], if (ipcMain.eventNames().includes(NTChannel.IPC_UP_2)) {
{ timeout: 1000, channel } return channel = NTChannel.IPC_UP_2
) } else {
return channel = NTChannel.IPC_UP_3
}
} }
for (const channel of [NTChannel.IPC_UP_2, NTChannel.IPC_UP_3]) {
// const channel = `IPC_UP_${windowId}` as NTChannel
try {
await testChannel(channel)
log(`check channel ${channel} success`)
availableChannel = channel
return
} catch (e) {
log(`check channel ${channel} failed`, e)
}
}
availableChannel = getBuildVersion() >= 28788 ? NTChannel.IPC_UP_3 : NTChannel.IPC_UP_2
}
export function invoke< export function invoke<
R extends Awaited<ReturnType<Extract<NTService[S][M], (...args: any) => unknown>>>, R extends Awaited<ReturnType<Extract<NTService[S][M], (...args: any) => unknown>>>,
S extends keyof NTService = any, S extends keyof NTService = any,
M extends keyof NTService[S] & string = any M extends keyof NTService[S] & string = any
>(method: Extract<unknown, `${S}/${M}`> | string, args: unknown[], options: InvokeOptions<R> = {}) { >(method: Extract<unknown, `${S}/${M}`> | string, args: unknown[], options: InvokeOptions<R> = {}) {
const className = options.className ?? NTClass.NT_API const className = options.className ?? NTClass.NT_API
// const channel = options.channel ?? getBuildVersion() >= 28788 ? NTChannel.IPC_UP_3 : NTChannel.IPC_UP_2 const channel = options.channel ?? getChannel()
const channel = options.channel ?? availableChannel!
const timeout = options.timeout ?? 5000 const timeout = options.timeout ?? 5000
const afterFirstCmd = options.afterFirstCmd ?? true const afterFirstCmd = options.afterFirstCmd ?? true
let eventName = className + '-' + channel[channel.length - 1] let eventName = className + '-' + channel[channel.length - 1]