Compare commits

...

2 Commits

Author SHA1 Message Date
b63f9f4530 chore(release): publish
- @egg/net-tool@1.23.0
2025-01-14 09:12:17 +00:00
42bd679248 feat(net-tool): 更新 LarkMessageService.update 方法,支持文本消息格式
All checks were successful
/ release (push) Successful in 25s
2025-01-14 09:11:53 +00:00
4 changed files with 18 additions and 4 deletions

2
package-lock.json generated
View File

@ -12394,7 +12394,7 @@
},
"packages/net-tool": {
"name": "@egg/net-tool",
"version": "1.22.0",
"version": "1.23.0",
"license": "ISC",
"dependencies": {
"@egg/logger": "^1.6.0",

View File

@ -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.23.0](http://yingbo.im:3000/zhaoyingbo/egg_tools/compare/@egg/net-tool@1.22.0...@egg/net-tool@1.23.0) (2025-01-14)
### Features
- **net-tool:** 更新 LarkMessageService.update 方法,支持文本消息格式 ([42bd679](http://yingbo.im:3000/zhaoyingbo/egg_tools/commits/42bd6792485acf2c8d0a61440db26fdc52900308))
# [1.22.0](http://yingbo.im:3000/zhaoyingbo/egg_tools/compare/@egg/net-tool@1.21.0...@egg/net-tool@1.22.0) (2025-01-12)
### Features

View File

@ -1,6 +1,6 @@
{
"name": "@egg/net-tool",
"version": "1.22.0",
"version": "1.23.0",
"description": "Net Tools for Egg projects",
"type": "module",
"main": "src/index.ts",

View File

@ -55,12 +55,20 @@ class LarkMessageService extends LarkBaseService {
* @param messageId id
* @param content JSON结构序列化后的字符串msgType对应不同内容
*/
async update(messageId: string, content: string | Record<string, any>) {
async update(
messageId: string,
content: string | Record<string, any>,
isText: boolean = false
) {
const path = `/im/v1/messages/${messageId}`
if (typeof content === "object") {
content = JSON.stringify(content)
}
return this.patch<Lark.BaseRes>(path, { content })
if (isText && !content.includes('"text"')) {
content = JSON.stringify({ text: content })
}
if (!isText) return this.patch<Lark.BaseRes>(path, { content })
return this.put<Lark.BaseRes>(path, { content, msg_type: "text" })
}
/**