diff --git a/src/common/config.ts b/src/common/config.ts index 5fb5ee5..ce2250f 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -52,7 +52,7 @@ export class ConfigUtil { autoDeleteFile: false, autoDeleteFileSecond: 60, musicSignUrl: '', - msgCacheExpire: 8000 + msgCacheExpire: 120 } if (!fs.existsSync(this.configPath)) { diff --git a/src/common/data.ts b/src/common/data.ts index 3f9770c..a875fc4 100644 --- a/src/common/data.ts +++ b/src/common/data.ts @@ -134,9 +134,12 @@ export function getSelfUin() { const messages: Map<string, RawMessage> = new Map() let expire: number -/** 缓存已撤回消息内容 */ -export function addMsgCache(msg: RawMessage) { - expire ??= getConfigUtil().getConfig().msgCacheExpire! +/** 缓存近期消息内容 */ +export async function addMsgCache(msg: RawMessage) { + expire ??= getConfigUtil().getConfig().msgCacheExpire! * 1000 + if (expire === 0) { + return + } const id = msg.msgId messages.set(id, msg) setTimeout(() => { @@ -144,7 +147,7 @@ export function addMsgCache(msg: RawMessage) { }, expire) } -/** 获取已撤回消息内容 */ +/** 获取近期消息内容 */ export function getMsgCache(msgId: string) { return messages.get(msgId) } \ No newline at end of file diff --git a/src/common/types.ts b/src/common/types.ts index 4705dd0..e7612b4 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -30,6 +30,7 @@ export interface Config { ffmpeg?: string // ffmpeg路径 musicSignUrl?: string ignoreBeforeLoginMsg?: boolean + /** 单位为秒 */ msgCacheExpire?: number } diff --git a/src/main/main.ts b/src/main/main.ts index 49868cd..7d758be 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -96,7 +96,7 @@ function onLoad() { } ipcMain.handle(CHANNEL_ERROR, async (event, arg) => { const ffmpegOk = await checkFfmpeg(getConfigUtil().getConfig().ffmpeg) - llonebotError.ffmpegError = ffmpegOk ? '' : '没有找到ffmpeg,音频只能发送wav和silk,视频尺寸可能异常' + llonebotError.ffmpegError = ffmpegOk ? '' : '没有找到 FFmpeg, 音频只能发送 WAV 和 SILK, 视频尺寸可能异常' let { httpServerError, wsServerError, otherError, ffmpegError } = llonebotError let error = `${otherError}\n${httpServerError}\n${wsServerError}\n${ffmpegError}` error = error.replace('\n\n', '\n') @@ -160,6 +160,7 @@ function onLoad() { peerUid: message.peerUid } message.msgShortId = MessageUnique.createMsg(peer, message.msgId) + addMsgCache(message) OB11Constructor.message(message) .then((msg) => { @@ -184,7 +185,7 @@ function onLoad() { } }) OB11Constructor.PrivateEvent(message).then((privateEvent) => { - log(message) + //log(message) if (privateEvent) { // log("post private event", privateEvent); postOb11Event(privateEvent) @@ -223,7 +224,6 @@ function onLoad() { if (!oriMessageId) { continue } - addMsgCache(message) OB11Constructor.RecallEvent(message, oriMessageId).then((recallEvent) => { if (recallEvent) { //log('post recall event', recallEvent) diff --git a/src/renderer/index.ts b/src/renderer/index.ts index 5015d46..7077b42 100644 --- a/src/renderer/index.ts +++ b/src/renderer/index.ts @@ -220,8 +220,8 @@ async function onSettingWindowCreated(view: Element) { SettingButton('打开', 'config-open-log-path'), ), SettingItem( - '已撤回消息内容缓存时长', - '单位为毫秒', + '消息内容缓存时长', + '单位为秒', `<div class="q-input"><input class="q-input__inner" data-config-key="msgCacheExpire" type="number" min="1" value="${config.msgCacheExpire}" placeholder="${config.msgCacheExpire}" /></div>`, ), ]),