feat(net-tool): 重构消息回复逻辑,新增设置回复消息ID和类型的方法
All checks were successful
/ release (push) Successful in 28s
All checks were successful
/ release (push) Successful in 28s
This commit is contained in:
parent
76eb1c4cfc
commit
60f14d6a94
@ -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 消息类型 包括:text、interactive
|
* @param msgType 消息类型 包括:text、interactive
|
||||||
* @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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user