refa: deps

This commit is contained in:
idranme 2024-08-02 12:00:13 +00:00
parent d0967785de
commit f3af0d18bc
8 changed files with 30 additions and 35 deletions

View File

@ -16,24 +16,21 @@
"author": "",
"license": "MIT",
"dependencies": {
"compressing": "^1.10.0",
"compressing": "^1.10.1",
"cors": "^2.8.5",
"express": "^4.18.2",
"fast-xml-parser": "^4.3.6",
"file-type": "^19.0.0",
"fluent-ffmpeg": "^2.1.2",
"express": "^4.19.2",
"fast-xml-parser": "^4.4.1",
"file-type": "^19.3.0",
"fluent-ffmpeg": "^2.1.3",
"level": "^8.0.1",
"silk-wasm": "^3.6.0",
"utf-8-validate": "^6.0.3",
"uuid": "^9.0.1",
"ws": "^8.16.0"
"silk-wasm": "^3.6.1",
"ws": "^8.18.0"
},
"devDependencies": {
"@types/express": "^4.17.20",
"@types/fluent-ffmpeg": "^2.1.24",
"@types/express": "^4.17.21",
"@types/fluent-ffmpeg": "^2.1.25",
"@types/node": "^20.11.24",
"@types/uuid": "^9.0.8",
"@types/ws": "^8.5.10",
"@types/ws": "^8.5.12",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"electron": "^29.0.1",
"electron-vite": "^2.0.0",

View File

@ -1,10 +1,10 @@
import { Level } from 'level'
const db = new Level(process.env['level_db_path'], { valueEncoding: 'json' })
const db = new Level(process.env['level_db_path'] as string, { valueEncoding: 'json' })
async function getGroupNotify() {
let keys = await db.keys().all()
let result = []
let result: string[] = []
for (const key of keys) {
// console.log(key)
if (key.startsWith('group_notify_')) {

View File

@ -4,9 +4,9 @@ import { decode, encode, getDuration, getWavFileInfo, isWav, isSilk } from 'silk
import { log } from './log'
import path from 'node:path'
import { TEMP_DIR } from './index'
import { v4 as uuidv4 } from 'uuid'
import { getConfigUtil } from '../config'
import { spawn } from 'node:child_process'
import { randomUUID } from 'node:crypto'
export async function encodeSilk(filePath: string) {
function getFileHeader(filePath: string) {
@ -61,7 +61,7 @@ export async function encodeSilk(filePath: string) {
try {
const file = await fsPromise.readFile(filePath)
const pttPath = path.join(TEMP_DIR, uuidv4())
const pttPath = path.join(TEMP_DIR, randomUUID())
if (!isSilk(file)) {
log(`语音文件${filePath}需要转换成silk`)
const _isWav = isWav(file)

View File

@ -1,13 +1,12 @@
import fs from 'fs'
import fsPromise from 'fs/promises'
import crypto from 'crypto'
import util from 'util'
import path from 'node:path'
import { v4 as uuidv4 } from 'uuid'
import { log, TEMP_DIR } from './index'
import { dbUtil } from '../db'
import * as fileType from 'file-type'
import { net } from 'electron'
import { randomUUID, createHash } from 'node:crypto'
export function isGIF(path: string) {
const buffer = Buffer.alloc(4)
@ -66,7 +65,7 @@ export function calculateFileMD5(filePath: string): Promise<string> {
return new Promise((resolve, reject) => {
// 创建一个流式读取器
const stream = fs.createReadStream(filePath)
const hash = crypto.createHash('md5')
const hash = createHash('md5')
stream.on('data', (data: Buffer) => {
// 当读取到数据时,更新哈希对象的状态
@ -109,7 +108,7 @@ export async function httpDownload(options: string | HttpDownloadOptions): Promi
}
}
}
const fetchRes = await net.fetch(url, {headers})
const fetchRes = await net.fetch(url, { headers })
if (!fetchRes.ok) throw new Error(`下载文件失败: ${fetchRes.statusText}`)
const blob = await fetchRes.blob()
@ -136,7 +135,7 @@ export async function uri2local(uri: string, fileName: string = null): Promise<U
isLocal: false,
}
if (!fileName) {
fileName = uuidv4()
fileName = randomUUID()
}
let filePath = path.join(TEMP_DIR, fileName)
let url = null
@ -178,7 +177,7 @@ export async function uri2local(uri: string, fileName: string = null): Promise<U
}
fileName = fileName.replace(/[/\\:*?"<>|]/g, '_')
res.fileName = fileName
filePath = path.join(TEMP_DIR, uuidv4() + fileName)
filePath = path.join(TEMP_DIR, randomUUID() + fileName)
fs.writeFileSync(filePath, buffer)
} catch (e: any) {
res.errMsg = `${url}下载失败,` + e.toString()

View File

@ -204,7 +204,7 @@ function onLoad() {
async function startReceiveHook() {
startHook().then()
if (getConfigUtil().getConfig().enablePoke) {
if ( qqPkgInfo.buildVersion > '23873'){
if (qqPkgInfo.buildVersion > '23873') {
log(`当前版本${qqPkgInfo.buildVersion}不支持发送戳一戳模块`)
}
else {
@ -216,7 +216,7 @@ function onLoad() {
pokeEvent = new OB11GroupPokeEvent(parseInt(id))
}
else {
pokeEvent = new OB11FriendPokeEvent(parseInt(id))
pokeEvent = new OB11FriendPokeEvent(parseInt(id), 0)
}
postOb11Event(pokeEvent)
})
@ -235,7 +235,7 @@ function onLoad() {
registerReceiveHook<{ msgList: Array<RawMessage> }>([ReceiveCmdS.UPDATE_MSG], async (payload) => {
for (const message of payload.msgList) {
const sentMessage = sentMessages[message.msgId]
if (sentMessage){
if (sentMessage) {
Object.assign(sentMessage, message)
}
log('message update', message.msgId, message)
@ -442,7 +442,7 @@ function onLoad() {
async function start() {
log('llonebot pid', process.pid)
const config = getConfigUtil().getConfig()
if (!config.enableLLOB){
if (!config.enableLLOB) {
log('LLOneBot 开关设置为关闭不启动LLOneBot')
return
}
@ -453,7 +453,7 @@ function onLoad() {
uidMaps[value] = key
}
})
try{
try {
log('start get groups')
const _groups = await NTQQGroupApi.getGroups()
log('_groups', _groups)

View File

@ -13,7 +13,6 @@ import {
uidMaps,
} from '@/common/data'
import { OB11GroupDecreaseEvent } from '../onebot11/event/notice/OB11GroupDecreaseEvent'
import { v4 as uuidv4 } from 'uuid'
import { postOb11Event } from '../onebot11/server/post-ob11-event'
import { getConfigUtil, HOOK_LOG } from '@/common/config'
import fs from 'fs'
@ -23,6 +22,7 @@ import { log } from '@/common/utils'
import { isNumeric, sleep } from '@/common/utils'
import { OB11Constructor } from '../onebot11/constructor'
import { OB11GroupCardEvent } from '../onebot11/event/notice/OB11GroupCardEvent'
import { randomUUID } from 'node:crypto'
export let hookApiCallbacks: Record<string, (apiReturn: any) => void> = {}
@ -203,7 +203,7 @@ export function registerReceiveHook<PayloadType>(
method: ReceiveCmd | ReceiveCmd[],
hookFunc: (payload: PayloadType) => void,
): string {
const id = uuidv4()
const id = randomUUID()
if (!Array.isArray(method)) {
method = [method]
}

View File

@ -1,10 +1,9 @@
import { ipcMain } from 'electron'
import { hookApiCallbacks, ReceiveCmd, ReceiveCmdS, registerReceiveHook, removeReceiveHook } from './hook'
import { v4 as uuidv4 } from 'uuid'
import { log } from '../common/utils/log'
import { NTQQWindow, NTQQWindowApi, NTQQWindows } from './api/window'
import { HOOK_LOG } from '../common/config'
import { randomUUID } from 'node:crypto'
export enum NTQQApiClass {
NT_API = 'ns-ntApi',
@ -130,7 +129,7 @@ export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
args = args ?? []
timeout = timeout ?? 5
afterFirstCmd = afterFirstCmd ?? true
const uuid = uuidv4()
const uuid = randomUUID()
HOOK_LOG && log('callNTQQApi', channel, className, methodName, args, uuid)
return new Promise((resolve: (data: ReturnType) => void, reject) => {
// log("callNTQQApiPromise", channel, className, methodName, args, uuid)

View File

@ -3,7 +3,7 @@ import { ActionName } from '../types'
import fs from 'fs'
import { join as joinPath } from 'node:path'
import { calculateFileMD5, httpDownload, TEMP_DIR } from '../../../common/utils'
import { v4 as uuid4 } from 'uuid'
import { randomUUID } from 'node:crypto'
interface Payload {
thread_count?: number
@ -22,7 +22,7 @@ export default class GoCQHTTPDownloadFile extends BaseAction<Payload, FileRespon
protected async _handle(payload: Payload): Promise<FileResponse> {
const isRandomName = !payload.name
let name = payload.name || uuid4()
let name = payload.name || randomUUID()
const filePath = joinPath(TEMP_DIR, name)
if (payload.base64) {