feat: 更新聊天记录获取逻辑,支持通过用户名排除提到的人
This commit is contained in:
parent
553f212cc8
commit
1377a84784
@ -9,15 +9,7 @@ const agent = async (ctx: Context.Data) => {
|
|||||||
larkCard,
|
larkCard,
|
||||||
larkService,
|
larkService,
|
||||||
appInfo,
|
appInfo,
|
||||||
larkBody: {
|
larkBody: { messageId, msgText, chatId, mentions, rawMsgText, openId },
|
||||||
messageId,
|
|
||||||
msgText,
|
|
||||||
chatId,
|
|
||||||
mentions,
|
|
||||||
rawMsgText,
|
|
||||||
openId,
|
|
||||||
mentionedRobot,
|
|
||||||
},
|
|
||||||
} = ctx
|
} = ctx
|
||||||
const cardGender = larkCard.child("groupAgent")
|
const cardGender = larkCard.child("groupAgent")
|
||||||
// 回复一个loading的卡片
|
// 回复一个loading的卡片
|
||||||
@ -44,7 +36,7 @@ const agent = async (ctx: Context.Data) => {
|
|||||||
mentions,
|
mentions,
|
||||||
senderOpenId: openId,
|
senderOpenId: openId,
|
||||||
excludedMessageIds: [message_id, messageId],
|
excludedMessageIds: [message_id, messageId],
|
||||||
excludeMentions: [mentionedRobot?.id?.open_id || ""],
|
excludeMentions: [appInfo.app_name],
|
||||||
})
|
})
|
||||||
// 如果没有聊天记录,返回错误信息
|
// 如果没有聊天记录,返回错误信息
|
||||||
if (chatHistory.length === 0) {
|
if (chatHistory.length === 0) {
|
||||||
|
@ -59,7 +59,7 @@ const getChatHistory = async (
|
|||||||
senderOpenId?: string
|
senderOpenId?: string
|
||||||
mentions?: LarkEvent.Mention[]
|
mentions?: LarkEvent.Mention[]
|
||||||
excludedMessageIds?: string[] // 不需要的消息 ID
|
excludedMessageIds?: string[] // 不需要的消息 ID
|
||||||
excludeMentions?: string[] // 不需要的提到的人
|
excludeMentions?: string[] // 不需要的提到的人,可以是openid,也可以是userName
|
||||||
}
|
}
|
||||||
): Promise<{
|
): Promise<{
|
||||||
messages: Message[]
|
messages: Message[]
|
||||||
@ -116,7 +116,10 @@ const getChatHistory = async (
|
|||||||
for (const mention of chat.mentions) {
|
for (const mention of chat.mentions) {
|
||||||
mentions.set(mention.id, mention.name)
|
mentions.set(mention.id, mention.name)
|
||||||
// 过滤掉不需要的提到的人
|
// 过滤掉不需要的提到的人
|
||||||
if (excludeMentions.includes(mention.id)) {
|
if (
|
||||||
|
excludeMentions.includes(mention.id) ||
|
||||||
|
excludeMentions.includes(mention.name)
|
||||||
|
) {
|
||||||
hasExcludeMention = true
|
hasExcludeMention = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ const genReport = async (
|
|||||||
chatId,
|
chatId,
|
||||||
startTime,
|
startTime,
|
||||||
endTime,
|
endTime,
|
||||||
|
excludeMentions: [appInfo.app_name],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if (chatHistory.length === 0) {
|
if (chatHistory.length === 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user