This commit is contained in:
idranme 2024-11-14 15:24:46 +08:00
parent e1e5c278b9
commit 1f02c98c8f
No known key found for this signature in database
GPG Key ID: D0F3677546E6ECD5
5 changed files with 40 additions and 49 deletions

View File

@ -2,6 +2,7 @@ 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'
import { Dict } from 'cosmokit'
export const hookApiCallbacks: Record<string, (res: any) => void> = {} export const hookApiCallbacks: Record<string, (res: any) => void> = {}
@ -45,7 +46,7 @@ export function startHook() {
const senderExclude = Symbol() const senderExclude = Symbol()
ipcMain.emit = new Proxy(ipcMain.emit, { ipcMain.emit = new Proxy(ipcMain.emit, {
apply(target, thisArg, args: [eventName: string, ...args: any]) { apply(target, thisArg, args: [channel: string, ...args: any]) {
if (args[2]?.eventName?.startsWith('ns-LoggerApi')) { if (args[2]?.eventName?.startsWith('ns-LoggerApi')) {
return target.apply(thisArg, args) return target.apply(thisArg, args)
} }
@ -56,7 +57,7 @@ export function startHook() {
if (event.sender && !event.sender[senderExclude]) { if (event.sender && !event.sender[senderExclude]) {
event.sender[senderExclude] = true event.sender[senderExclude] = true
event.sender.send = new Proxy(event.sender.send, { event.sender.send = new Proxy(event.sender.send, {
apply(target, thisArg, args: any[]) { apply(target, thisArg, args: [channel: string, meta: Dict, data: Dict[]]) {
if (args[1].eventName?.startsWith('ns-LoggerApi')) { if (args[1].eventName?.startsWith('ns-LoggerApi')) {
return target.apply(thisArg, args) return target.apply(thisArg, args)
} }

View File

@ -11,7 +11,7 @@ export class Native {
public activated = false public activated = false
private crychic?: Dict private crychic?: Dict
private seq = 0 private seq = 0
private cb: Map<number, Function> = new Map() private cb: Map<number, (res: any) => void> = new Map()
constructor(private ctx: Context) { constructor(private ctx: Context) {
ctx.on('ready', () => { ctx.on('ready', () => {

View File

@ -7,10 +7,7 @@ import { ChatCacheListItemBasic, CacheFileType } from '@/ntqqapi/types'
export default class CleanCache extends BaseAction<void, void> { export default class CleanCache extends BaseAction<void, void> {
actionName = ActionName.CleanCache actionName = ActionName.CleanCache
protected _handle(): Promise<void> { protected async _handle(): Promise<void> {
return new Promise<void>(async (res, rej) => {
try {
// dbUtil.clearCache()
const cacheFilePaths: string[] = [] const cacheFilePaths: string[] = []
await this.ctx.ntFileCacheApi.setCacheSilentScan(false) await this.ctx.ntFileCacheApi.setCacheSilentScan(false)
@ -49,20 +46,13 @@ export default class CleanCache extends BaseAction<void, void> {
for (const name in CacheFileType) { for (const name in CacheFileType) {
if (!isNaN(parseInt(name))) continue if (!isNaN(parseInt(name))) continue
const fileTypeAny: any = CacheFileType[name] const fileType = CacheFileType[name] as unknown as CacheFileType
const fileType: CacheFileType = fileTypeAny
cacheFileList.push(...(await this.ctx.ntFileCacheApi.getFileCacheInfo(fileType)).infos.map((file) => file.fileKey)) cacheFileList.push(...(await this.ctx.ntFileCacheApi.getFileCacheInfo(fileType)).infos.map((file) => file.fileKey))
} }
// 一并清除 // 一并清除
await this.ctx.ntFileCacheApi.clearChatCache(chatCacheList, cacheFileList) await this.ctx.ntFileCacheApi.clearChatCache(chatCacheList, cacheFileList)
res()
} catch (e) {
console.error('清理缓存时发生了错误')
rej(e)
}
})
} }
} }

View File

@ -221,7 +221,7 @@ export class MessageEncoder {
} }
} }
async generate(content: any[]) { async generate(content: OB11MessageData[]) {
await this.render(content) await this.render(content)
return { return {
multiMsgItems: [{ multiMsgItems: [{

View File

@ -91,7 +91,7 @@ class SatoriAdapter extends Service {
input.subMsgType === 12 && input.subMsgType === 12 &&
input.elements[0]?.grayTipElement?.xmlElement?.templId === '10382' input.elements[0]?.grayTipElement?.xmlElement?.templId === '10382'
) { ) {
// 机器人被表情回应
} }
else { else {
// 普通的消息 // 普通的消息