From 1377a8478421f21672df579322070fcbd83fcc8a Mon Sep 17 00:00:00 2001 From: zhaoyingbo Date: Wed, 4 Dec 2024 10:05:25 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87=E7=94=A8=E6=88=B7=E5=90=8D?= =?UTF-8?q?=E6=8E=92=E9=99=A4=E6=8F=90=E5=88=B0=E7=9A=84=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/groupAgent/agent.ts | 12 ++---------- controller/groupAgent/chatHistory.ts | 7 +++++-- controller/groupAgent/report.ts | 1 + 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/controller/groupAgent/agent.ts b/controller/groupAgent/agent.ts index 95e4ce2..616dc86 100644 --- a/controller/groupAgent/agent.ts +++ b/controller/groupAgent/agent.ts @@ -9,15 +9,7 @@ const agent = async (ctx: Context.Data) => { larkCard, larkService, appInfo, - larkBody: { - messageId, - msgText, - chatId, - mentions, - rawMsgText, - openId, - mentionedRobot, - }, + larkBody: { messageId, msgText, chatId, mentions, rawMsgText, openId }, } = ctx const cardGender = larkCard.child("groupAgent") // 回复一个loading的卡片 @@ -44,7 +36,7 @@ const agent = async (ctx: Context.Data) => { mentions, senderOpenId: openId, excludedMessageIds: [message_id, messageId], - excludeMentions: [mentionedRobot?.id?.open_id || ""], + excludeMentions: [appInfo.app_name], }) // 如果没有聊天记录,返回错误信息 if (chatHistory.length === 0) { diff --git a/controller/groupAgent/chatHistory.ts b/controller/groupAgent/chatHistory.ts index 9c4a24a..036c8c9 100644 --- a/controller/groupAgent/chatHistory.ts +++ b/controller/groupAgent/chatHistory.ts @@ -59,7 +59,7 @@ const getChatHistory = async ( senderOpenId?: string mentions?: LarkEvent.Mention[] excludedMessageIds?: string[] // 不需要的消息 ID - excludeMentions?: string[] // 不需要的提到的人 + excludeMentions?: string[] // 不需要的提到的人,可以是openid,也可以是userName } ): Promise<{ messages: Message[] @@ -116,7 +116,10 @@ const getChatHistory = async ( for (const mention of chat.mentions) { mentions.set(mention.id, mention.name) // 过滤掉不需要的提到的人 - if (excludeMentions.includes(mention.id)) { + if ( + excludeMentions.includes(mention.id) || + excludeMentions.includes(mention.name) + ) { hasExcludeMention = true } } diff --git a/controller/groupAgent/report.ts b/controller/groupAgent/report.ts index 1ef2a94..cfb5eab 100644 --- a/controller/groupAgent/report.ts +++ b/controller/groupAgent/report.ts @@ -55,6 +55,7 @@ const genReport = async ( chatId, startTime, endTime, + excludeMentions: [appInfo.app_name], } ) if (chatHistory.length === 0) {