mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
59a11faa7f | ||
![]() |
3b3795c946 | ||
![]() |
ff18937828 | ||
![]() |
65d02d7f21 | ||
![]() |
9cb8ba017e | ||
![]() |
1e579858b8 |
@@ -4,7 +4,7 @@
|
|||||||
"name": "LLOneBot",
|
"name": "LLOneBot",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
||||||
"version": "3.29.4",
|
"version": "3.29.5",
|
||||||
"icon": "./icon.webp",
|
"icon": "./icon.webp",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
"@types/fluent-ffmpeg": "^2.1.25",
|
"@types/fluent-ffmpeg": "^2.1.25",
|
||||||
"@types/node": "^20.14.15",
|
"@types/node": "^20.14.15",
|
||||||
"@types/ws": "^8.5.12",
|
"@types/ws": "^8.5.12",
|
||||||
"electron": "^29.1.4",
|
"electron": "^31.4.0",
|
||||||
"electron-vite": "^2.3.0",
|
"electron-vite": "^2.3.0",
|
||||||
"typescript": "^5.5.4",
|
"typescript": "^5.5.4",
|
||||||
"vite": "^5.4.1",
|
"vite": "^5.4.1",
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
import { Level } from 'level'
|
|
||||||
|
|
||||||
const db = new Level(process.env['level_db_path'] as string, { valueEncoding: 'json' })
|
|
||||||
|
|
||||||
async function getGroupNotify() {
|
|
||||||
let keys = await db.keys().all()
|
|
||||||
let result: string[] = []
|
|
||||||
for (const key of keys) {
|
|
||||||
// console.log(key)
|
|
||||||
if (key.startsWith('group_notify_')) {
|
|
||||||
result.push(key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
getGroupNotify().then(console.log)
|
|
@@ -5,9 +5,7 @@ import path from 'node:path'
|
|||||||
import { getSelfUin } from './data'
|
import { getSelfUin } from './data'
|
||||||
import { DATA_DIR } from './utils'
|
import { DATA_DIR } from './utils'
|
||||||
|
|
||||||
export const HOOK_LOG = false
|
//export const HOOK_LOG = false
|
||||||
|
|
||||||
export const ALLOW_SEND_TEMP_MSG = false
|
|
||||||
|
|
||||||
export class ConfigUtil {
|
export class ConfigUtil {
|
||||||
private readonly configPath: string
|
private readonly configPath: string
|
||||||
|
@@ -16,7 +16,7 @@ import {
|
|||||||
setSelfInfo
|
setSelfInfo
|
||||||
} from '@/common/data'
|
} from '@/common/data'
|
||||||
import { postOb11Event } from '../onebot11/server/post-ob11-event'
|
import { postOb11Event } from '../onebot11/server/post-ob11-event'
|
||||||
import { getConfigUtil, HOOK_LOG } from '@/common/config'
|
import { getConfigUtil } from '@/common/config'
|
||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import { log } from '@/common/utils'
|
import { log } from '@/common/utils'
|
||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
@@ -81,7 +81,7 @@ export function hookNTQQApiReceive(window: BrowserWindow) {
|
|||||||
const originalSend = window.webContents.send
|
const originalSend = window.webContents.send
|
||||||
const patchSend = (channel: string, ...args: NTQQApiReturnData) => {
|
const patchSend = (channel: string, ...args: NTQQApiReturnData) => {
|
||||||
// console.log("hookNTQQApiReceive", channel, args)
|
// console.log("hookNTQQApiReceive", channel, args)
|
||||||
let isLogger = false
|
/*let isLogger = false
|
||||||
try {
|
try {
|
||||||
isLogger = args[0]?.eventName?.startsWith('ns-LoggerApi')
|
isLogger = args[0]?.eventName?.startsWith('ns-LoggerApi')
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
@@ -91,7 +91,7 @@ export function hookNTQQApiReceive(window: BrowserWindow) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('hook log error', e, args)
|
log('hook log error', e, args)
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
try {
|
try {
|
||||||
if (args?.[1] instanceof Array) {
|
if (args?.[1] instanceof Array) {
|
||||||
for (let receiveData of args?.[1]) {
|
for (let receiveData of args?.[1]) {
|
||||||
@@ -145,9 +145,9 @@ export function hookNTQQApiCall(window: BrowserWindow) {
|
|||||||
isLogger = args[3][0].eventName.startsWith('ns-LoggerApi')
|
isLogger = args[3][0].eventName.startsWith('ns-LoggerApi')
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
if (!isLogger) {
|
if (!isLogger) {
|
||||||
try {
|
/*try {
|
||||||
HOOK_LOG && log('call NTQQ api', thisArg, args)
|
HOOK_LOG && log('call NTQQ api', thisArg, args)
|
||||||
} catch (e) { }
|
} catch (e) { }*/
|
||||||
try {
|
try {
|
||||||
const _args: unknown[] = args[3][1]
|
const _args: unknown[] = args[3][1]
|
||||||
const cmdName: NTQQApiMethod = _args[0] as NTQQApiMethod
|
const cmdName: NTQQApiMethod = _args[0] as NTQQApiMethod
|
||||||
@@ -181,16 +181,16 @@ export function hookNTQQApiCall(window: BrowserWindow) {
|
|||||||
const proxyIpcInvoke = new Proxy(ipc_invoke_proxy, {
|
const proxyIpcInvoke = new Proxy(ipc_invoke_proxy, {
|
||||||
apply(target, thisArg, args) {
|
apply(target, thisArg, args) {
|
||||||
// console.log(args);
|
// console.log(args);
|
||||||
HOOK_LOG && log('call NTQQ invoke api', thisArg, args)
|
//HOOK_LOG && log('call NTQQ invoke api', thisArg, args)
|
||||||
args[0]['_replyChannel']['sendReply'] = new Proxy(args[0]['_replyChannel']['sendReply'], {
|
args[0]['_replyChannel']['sendReply'] = new Proxy(args[0]['_replyChannel']['sendReply'], {
|
||||||
apply(sendtarget, sendthisArg, sendargs) {
|
apply(sendtarget, sendthisArg, sendargs) {
|
||||||
sendtarget.apply(sendthisArg, sendargs)
|
sendtarget.apply(sendthisArg, sendargs)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let ret = target.apply(thisArg, args)
|
let ret = target.apply(thisArg, args)
|
||||||
try {
|
/*try {
|
||||||
HOOK_LOG && log('call NTQQ invoke api return', ret)
|
HOOK_LOG && log('call NTQQ invoke api return', ret)
|
||||||
} catch (e) { }
|
} catch (e) { }*/
|
||||||
return ret
|
return ret
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import { ipcMain } from 'electron'
|
import { ipcMain } from 'electron'
|
||||||
import { hookApiCallbacks, ReceiveCmd, ReceiveCmdS, registerReceiveHook, removeReceiveHook } from './hook'
|
import { hookApiCallbacks, ReceiveCmd, ReceiveCmdS, registerReceiveHook, removeReceiveHook } from './hook'
|
||||||
import { log } from '../common/utils/log'
|
import { log } from '../common/utils/log'
|
||||||
import { HOOK_LOG } from '../common/config'
|
|
||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
|
|
||||||
export enum NTQQApiClass {
|
export enum NTQQApiClass {
|
||||||
@@ -15,6 +14,7 @@ export enum NTQQApiClass {
|
|||||||
SKEY_API = 'ns-SkeyApi',
|
SKEY_API = 'ns-SkeyApi',
|
||||||
GROUP_HOME_WORK = 'ns-GroupHomeWork',
|
GROUP_HOME_WORK = 'ns-GroupHomeWork',
|
||||||
GROUP_ESSENCE = 'ns-GroupEssence',
|
GROUP_ESSENCE = 'ns-GroupEssence',
|
||||||
|
NODE_STORE_API = 'ns-NodeStoreApi'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NTQQApiMethod {
|
export enum NTQQApiMethod {
|
||||||
@@ -129,7 +129,7 @@ export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
|
|||||||
timeout = timeout ?? 5
|
timeout = timeout ?? 5
|
||||||
afterFirstCmd = afterFirstCmd ?? true
|
afterFirstCmd = afterFirstCmd ?? true
|
||||||
const uuid = randomUUID()
|
const uuid = randomUUID()
|
||||||
HOOK_LOG && log('callNTQQApi', channel, className, methodName, args, uuid)
|
//HOOK_LOG && log('callNTQQApi', channel, className, methodName, args, uuid)
|
||||||
return new Promise((resolve: (data: ReturnType) => void, reject) => {
|
return new Promise((resolve: (data: ReturnType) => void, reject) => {
|
||||||
// log("callNTQQApiPromise", channel, className, methodName, args, uuid)
|
// log("callNTQQApiPromise", channel, className, methodName, args, uuid)
|
||||||
const _timeout = timeout * 1000
|
const _timeout = timeout * 1000
|
||||||
@@ -202,25 +202,4 @@ export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
|
|||||||
export interface GeneralCallResult {
|
export interface GeneralCallResult {
|
||||||
result: number // 0: success
|
result: number // 0: success
|
||||||
errMsg: string
|
errMsg: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NTQQApi {
|
|
||||||
static async call(className: NTQQApiClass, cmdName: string, args: any[]) {
|
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
|
||||||
className,
|
|
||||||
methodName: cmdName,
|
|
||||||
args: [...args],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
static async fetchUnitedCommendConfig() {
|
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
|
||||||
methodName: NTQQApiMethod.FETCH_UNITED_COMMEND_CONFIG,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groups: ['100243'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
@@ -12,7 +12,7 @@ class GetGroupList extends BaseAction<Payload, OB11Group[]> {
|
|||||||
actionName = ActionName.GetGroupList
|
actionName = ActionName.GetGroupList
|
||||||
|
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
const groupList = await NTQQGroupApi.getGroups(payload?.no_cache === true || payload.no_cache === 'true')
|
const groupList = await NTQQGroupApi.getGroups(payload?.no_cache === true || payload?.no_cache === 'true')
|
||||||
return OB11Constructor.groups(groupList)
|
return OB11Constructor.groups(groupList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1 +1 @@
|
|||||||
export const version = '3.29.4'
|
export const version = '3.29.5'
|
||||||
|
Reference in New Issue
Block a user