feat(net-tool): 重构消息回复逻辑,新增设置回复消息ID和类型的方法
All checks were successful
/ release (push) Successful in 28s

This commit is contained in:
zhaoyingbo 2025-01-25 09:30:29 +00:00
parent 76eb1c4cfc
commit 60f14d6a94

View File

@ -144,28 +144,35 @@ class LarkMessageService extends LarkBaseService {
return this.reply(messageId, "interactive", content) return this.reply(messageId, "interactive", content)
} }
private repliedMessageId: string = "";
private replyMessageId: string = "";
private replyMsgType: "text" | "interactive" = "interactive";
/** /**
* * ID和类型
* @param messageId ID * @param messageId ID
* @param msgType textinteractive * @param msgType textinteractive
* @returns
*/ */
updateReplyMessage( setReplyMessage(messageId: string, msgType: "text" | "interactive" = "interactive") {
messageId: string, this.replyMessageId = messageId;
msgType: "text" | "interactive" = "interactive" this.replyMsgType = msgType;
) { }
let repliedMessageId = ""
return async (content: string) => { /**
if (repliedMessageId) { *
await this.update(repliedMessageId, content, msgType === "text") * @param content
return repliedMessageId * @returns ID
} */
const res = await this.reply(messageId, msgType, content) async updateOrReplyMessage(content: string) {
if ("data" in res) { if (this.repliedMessageId) {
repliedMessageId = res.data.message_id await this.update(this.repliedMessageId, content, this.replyMsgType === "text")
} return this.repliedMessageId
return repliedMessageId
} }
const res = await this.reply(this.replyMessageId, this.replyMsgType, content)
if ("data" in res) {
this.repliedMessageId = res.data.message_id
}
return this.repliedMessageId
} }
} }