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)