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",
"express": "^5.0.1",
"fluent-ffmpeg": "^2.1.3",
"minato": "^3.6.0",
"minato": "^3.6.1",
"protobufjs": "^7.4.0",
"silk-wasm": "^3.6.3",
"ts-case-convert": "^2.1.0",
@ -35,14 +35,14 @@
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/fluent-ffmpeg": "^2.1.26",
"@types/fluent-ffmpeg": "^2.1.27",
"@types/node": "^20.14.15",
"@types/ws": "^8.5.12",
"@types/ws": "^8.5.13",
"electron": "^31.4.0",
"electron-vite": "^2.3.0",
"protobufjs-cli": "^1.1.3",
"typescript": "^5.6.3",
"vite": "^5.4.10 ",
"vite": "^5.4.10",
"vite-plugin-cp": "^4.0.8"
},
"packageManager": "yarn@4.5.1"

View File

@ -35,7 +35,6 @@ import {
NTQQWindowApi
} from '../ntqqapi/api'
import { existsSync, mkdirSync } from 'node:fs'
import { checkChanelId } from '@/ntqqapi/ntcall'
declare module 'cordis' {
interface Events {
@ -185,7 +184,6 @@ function onLoad() {
if (config.enableLLOB && (config.satori.enable || config.ob11.enable)) {
startHook()
await checkChanelId()
await ctx.sleep(600)
} else {
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 { randomUUID } from 'node:crypto'
import { ipcMain } from 'electron'
@ -40,7 +40,7 @@ const callHooks: Array<{
}> = []
export function startHook() {
log("start hook")
log('start hook')
const senderExclude = Symbol()

View File

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