From 5cdca77fea67bc6c36b21961dcee473186754bda Mon Sep 17 00:00:00 2001 From: hanshino Date: Fri, 13 Dec 2024 22:17:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E5=B0=8D=E8=A9=B1=E7=B4=80=E9=8C=84=E7=9A=84=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/app.js | 1 + app/src/controller/application/OpenaiController.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/app/src/app.js b/app/src/app.js index 5f546b9..1b77712 100644 --- a/app/src/app.js +++ b/app/src/app.js @@ -282,6 +282,7 @@ async function OrderBased(context, { next }) { context.replyFlex("實用連結", carousel); }), text(".test", () => pushMessage({ message: "test", token: process.env.LINE_NOTIFY_TOKEN })), + text("/resetsession", OpenaiController.resetSession), route("*", next), ]); } diff --git a/app/src/controller/application/OpenaiController.js b/app/src/controller/application/OpenaiController.js index c495754..4608292 100644 --- a/app/src/controller/application/OpenaiController.js +++ b/app/src/controller/application/OpenaiController.js @@ -89,6 +89,13 @@ exports.recordSession = async function (context, { next }) { return next; }; +exports.resetSession = async function (context) { + const sourceType = get(context, "event.source.type"); + const sourceId = get(context, `event.source.${sourceType}Id`); + await redis.del(format(groupSessionKeyTemplate, sourceId)); + await context.replyText("已經將對話紀錄清空"); +}; + /** * 紀錄對話 * @param {String} groupId