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) {