From f8f01866657730948c32000785df13090e5bb1d2 Mon Sep 17 00:00:00 2001 From: zhaoyingbo Date: Mon, 2 Dec 2024 08:30:17 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=8E=92=E9=99=A4?= =?UTF-8?q?=E6=B6=88=E6=81=AFID=E5=8F=82=E6=95=B0=E4=BB=A5=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=81=8A=E5=A4=A9=E8=AE=B0=E5=BD=95=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/groupAgent/agent.ts | 1 + controller/groupAgent/chatHistory.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/controller/groupAgent/agent.ts b/controller/groupAgent/agent.ts index 7762c87..b994960 100644 --- a/controller/groupAgent/agent.ts +++ b/controller/groupAgent/agent.ts @@ -35,6 +35,7 @@ const agent = async (ctx: Context.Data) => { endTime, mentions, senderOpenId: openId, + excludedMessageIds: [message_id, messageId], }) // 如果没有聊天记录,返回错误信息 if (chatHistory.length === 0) { diff --git a/controller/groupAgent/chatHistory.ts b/controller/groupAgent/chatHistory.ts index 8201821..1abfa75 100644 --- a/controller/groupAgent/chatHistory.ts +++ b/controller/groupAgent/chatHistory.ts @@ -50,12 +50,14 @@ const getChatHistory = async ( endTime, senderOpenId, mentions: targetUsers, + excludedMessageIds = [], // 新增参数 }: { chatId: string startTime: string endTime: string senderOpenId?: string mentions?: LarkEvent.Mention[] + excludedMessageIds?: string[] // 新增参数类型 } ): Promise<{ messages: Message[] @@ -106,6 +108,10 @@ const getChatHistory = async ( // 遍历历史消息 for (const chat of chatHistory) { + // 过滤掉不需要的消息 ID + if (excludedMessageIds.includes(chat.message_id)) { + continue + } if (chat.mentions) { for (const mention of chat.mentions) { mentions.set(mention.id, mention.name)