From ffd2d8f8628c522f4d6ebf927a32acd0f053a55f Mon Sep 17 00:00:00 2001 From: misaka20002 <40714502+misaka20002@users.noreply.github.com> Date: Fri, 11 Oct 2024 23:57:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20mjp=20=E4=BD=BF=E7=94=A8=20redis=20?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=AF=8F=E4=B8=80=E4=BD=8D=E7=BE=A4=E6=88=90?= =?UTF-8?q?=E5=91=98=E6=9C=80=E8=BF=91=E7=9A=84taskID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/MJ_Painting.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/MJ_Painting.js b/apps/MJ_Painting.js index 8aa10f2..2b50fa1 100644 --- a/apps/MJ_Painting.js +++ b/apps/MJ_Painting.js @@ -40,7 +40,6 @@ export class MJ_Painting extends plugin { } ] }) - this.lastTaskId = null } async setConfig(e) { @@ -120,7 +119,7 @@ export class MJ_Painting extends plugin { if (result) { await this.reply(`图片生成完成!\n原始提示词:${prompt}\n任务ID:${taskId}\n图片链接:${result.imageUrl}`) await this.reply(segment.image(result.imageUrl)) - this.lastTaskId = taskId + redis.set(`sf_plugin:MJ_Painting:lastTaskId:${e.user_id}`, taskId, { EX: 7 * 24 * 60 * 60 }); // 写入redis,有效期7天 } else { await this.reply('生成图片失败,请稍后重试。') } @@ -225,7 +224,7 @@ export class MJ_Painting extends plugin { const match = e.msg.match(/^#(放大|微调|重绘)(左上|右上|左下|右下)\s*(.*)$/) if (match) { const [, action, position, taskId] = match - let useTaskId = taskId.trim() || this.lastTaskId + let useTaskId = taskId.trim() || await redis.get(`sf_plugin:MJ_Painting:lastTaskId:${e.user_id}`) if (!useTaskId) { await this.reply('请提供任务ID或先生成一张图片。') @@ -262,7 +261,7 @@ export class MJ_Painting extends plugin { if (result) { await this.reply(`操作完成!\n操作类型:${action}${position}\n新任务ID:${newTaskId}\n图片链接:${result.imageUrl}`) await this.reply(segment.image(result.imageUrl)) - this.lastTaskId = newTaskId + redis.set(`sf_plugin:MJ_Painting:lastTaskId:${e.user_id}`, newTaskId, { EX: 7 * 24 * 60 * 60 }); // 写入redis,有效期7天 } else { await this.reply('操作失败,请稍后重试。') }