Compare commits
2 Commits
@egg/net-t
...
@egg/net-t
Author | SHA1 | Date | |
---|---|---|---|
c8ef119f36 | |||
60f14d6a94 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -12394,7 +12394,7 @@
|
||||
},
|
||||
"packages/net-tool": {
|
||||
"name": "@egg/net-tool",
|
||||
"version": "1.27.0",
|
||||
"version": "1.28.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@egg/logger": "^1.6.0",
|
||||
|
@ -3,6 +3,12 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
# [1.28.0](http://yingbo.im:3000/zhaoyingbo/egg_tools/compare/@egg/net-tool@1.27.0...@egg/net-tool@1.28.0) (2025-01-25)
|
||||
|
||||
### Features
|
||||
|
||||
- **net-tool:** 重构消息回复逻辑,新增设置回复消息ID和类型的方法 ([60f14d6](http://yingbo.im:3000/zhaoyingbo/egg_tools/commits/60f14d6a94cdc8172ca22849d872218829b72ced))
|
||||
|
||||
# [1.27.0](http://yingbo.im:3000/zhaoyingbo/egg_tools/compare/@egg/net-tool@1.26.2...@egg/net-tool@1.27.0) (2025-01-24)
|
||||
|
||||
### Features
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@egg/net-tool",
|
||||
"version": "1.27.0",
|
||||
"version": "1.28.0",
|
||||
"description": "Net Tools for Egg projects",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
|
@ -144,28 +144,35 @@ class LarkMessageService extends LarkBaseService {
|
||||
return this.reply(messageId, "interactive", content)
|
||||
}
|
||||
|
||||
private repliedMessageId: string = "";
|
||||
private replyMessageId: string = "";
|
||||
private replyMsgType: "text" | "interactive" = "interactive";
|
||||
|
||||
/**
|
||||
* 更新或回复消息
|
||||
* 设置回复消息的ID和类型
|
||||
* @param messageId 消息ID
|
||||
* @param msgType 消息类型 包括:text、interactive
|
||||
* @returns 一个异步函数,用于更新或回复消息
|
||||
*/
|
||||
updateReplyMessage(
|
||||
messageId: string,
|
||||
msgType: "text" | "interactive" = "interactive"
|
||||
) {
|
||||
let repliedMessageId = ""
|
||||
return async (content: string) => {
|
||||
if (repliedMessageId) {
|
||||
await this.update(repliedMessageId, content, msgType === "text")
|
||||
return repliedMessageId
|
||||
}
|
||||
const res = await this.reply(messageId, msgType, content)
|
||||
if ("data" in res) {
|
||||
repliedMessageId = res.data.message_id
|
||||
}
|
||||
return repliedMessageId
|
||||
setReplyMessage(messageId: string, msgType: "text" | "interactive" = "interactive") {
|
||||
this.replyMessageId = messageId;
|
||||
this.replyMsgType = msgType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新或回复消息
|
||||
* @param content 消息内容
|
||||
* @returns 更新或回复的消息ID
|
||||
*/
|
||||
async updateOrReplyMessage(content: string) {
|
||||
if (this.repliedMessageId) {
|
||||
await this.update(this.repliedMessageId, content, this.replyMsgType === "text")
|
||||
return this.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