refactor(net-tool): 优化消息历史记录获取和回复消息设置逻辑
All checks were successful
/ release (push) Successful in 23s

This commit is contained in:
zhaoyingbo 2025-01-25 09:32:38 +00:00
parent c8ef119f36
commit 6da9ef7748

View File

@ -76,7 +76,7 @@ class LarkMessageService extends LarkBaseService {
} }
/** /**
* <EFBFBD><EFBFBD><EFBFBD> *
* @param chatId ID * @param chatId ID
* @param startTime * @param startTime
* @param endTime * @param endTime
@ -144,18 +144,21 @@ class LarkMessageService extends LarkBaseService {
return this.reply(messageId, "interactive", content) return this.reply(messageId, "interactive", content)
} }
private repliedMessageId: string = ""; private repliedMessageId: string = ""
private replyMessageId: string = ""; private replyMessageId: string = ""
private replyMsgType: "text" | "interactive" = "interactive"; private replyMsgType: "text" | "interactive" = "interactive"
/** /**
* ID和类型 * ID和类型
* @param messageId ID * @param messageId ID
* @param msgType textinteractive * @param msgType textinteractive
*/ */
setReplyMessage(messageId: string, msgType: "text" | "interactive" = "interactive") { setReplyMessage(
this.replyMessageId = messageId; messageId: string,
this.replyMsgType = msgType; msgType: "text" | "interactive" = "interactive"
) {
this.replyMessageId = messageId
this.replyMsgType = msgType
} }
/** /**
@ -165,10 +168,18 @@ class LarkMessageService extends LarkBaseService {
*/ */
async updateOrReplyMessage(content: string) { async updateOrReplyMessage(content: string) {
if (this.repliedMessageId) { if (this.repliedMessageId) {
await this.update(this.repliedMessageId, content, this.replyMsgType === "text") await this.update(
this.repliedMessageId,
content,
this.replyMsgType === "text"
)
return this.repliedMessageId return this.repliedMessageId
} }
const res = await this.reply(this.replyMessageId, this.replyMsgType, content) const res = await this.reply(
this.replyMessageId,
this.replyMsgType,
content
)
if ("data" in res) { if ("data" in res) {
this.repliedMessageId = res.data.message_id this.repliedMessageId = res.data.message_id
} }