Skip to content

Commit

Permalink
feat: 新增重置對話紀錄的指令功能
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshino committed Dec 13, 2024
1 parent 563e852 commit 5cdca77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]);
}
Expand Down
7 changes: 7 additions & 0 deletions app/src/controller/application/OpenaiController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5cdca77

Please sign in to comment.