refactor(net-tool): 优化消息历史记录获取和回复消息设置逻辑
All checks were successful
/ release (push) Successful in 23s
All checks were successful
/ release (push) Successful in 23s
This commit is contained in:
parent
c8ef119f36
commit
6da9ef7748
@ -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 消息类型 包括:text、interactive
|
* @param msgType 消息类型 包括:text、interactive
|
||||||
*/
|
*/
|
||||||
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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user