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