feat: 更新聊天记录获取逻辑,支持通过用户名排除提到的人
This commit is contained in:
parent
553f212cc8
commit
1377a84784
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ const genReport = async (
|
||||
chatId,
|
||||
startTime,
|
||||
endTime,
|
||||
excludeMentions: [appInfo.app_name],
|
||||
}
|
||||
)
|
||||
if (chatHistory.length === 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user