Compare commits
2 Commits
@egg/lark-
...
@egg/lark-
Author | SHA1 | Date | |
---|---|---|---|
07353b00aa | |||
fc8399e10b |
2
package-lock.json
generated
2
package-lock.json
generated
@ -12373,7 +12373,7 @@
|
||||
},
|
||||
"packages/lark-msg-tool": {
|
||||
"name": "@egg/lark-msg-tool",
|
||||
"version": "1.20.0",
|
||||
"version": "1.21.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.21.0](http://yingbo.im:3000/zhaoyingbo/egg_tools/compare/@egg/lark-msg-tool@1.20.0...@egg/lark-msg-tool@1.21.0) (2024-12-17)
|
||||
|
||||
### Features
|
||||
|
||||
- **lark-msg-tool:** 重构用户Id和OpenId获取方法以支持事件和动作消息体 ([fc8399e](http://yingbo.im:3000/zhaoyingbo/egg_tools/commits/fc8399e10bc9d6fa7a70fe6fb45ce5189c5fa914))
|
||||
|
||||
# [1.20.0](http://yingbo.im:3000/zhaoyingbo/egg_tools/compare/@egg/lark-msg-tool@1.19.0...@egg/lark-msg-tool@1.20.0) (2024-12-17)
|
||||
|
||||
### Features
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@egg/lark-msg-tool",
|
||||
"version": "1.20.0",
|
||||
"version": "1.21.0",
|
||||
"description": "Lark Msg Tools for Egg projects",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
|
@ -101,8 +101,6 @@ class LarkBody {
|
||||
this.eventType = this.getEventType(eventBody)
|
||||
this.isMessageEvent = this.getIsMessageEvent(eventBody)
|
||||
this.msgType = this.getMsgType(eventBody)
|
||||
this.userId = this.getUserId(eventBody)
|
||||
this.openId = this.getOpenId(eventBody)
|
||||
this.msgText = this.getMsgText(eventBody)
|
||||
this.rawMsgText = this.getRawMsgText(eventBody)
|
||||
this.chatType = this.getChatType(eventBody)
|
||||
@ -121,6 +119,8 @@ class LarkBody {
|
||||
|
||||
this.chatId = this.getChatId(body)
|
||||
this.messageId = this.getMessageId(body)
|
||||
this.userId = this.getUserId(body)
|
||||
this.openId = this.getOpenId(body)
|
||||
this.isLarkBody = this.isEvent || this.isAction
|
||||
}
|
||||
|
||||
@ -169,24 +169,6 @@ class LarkBody {
|
||||
return body?.event?.message?.message_type
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户Id
|
||||
* @param body 事件消息体
|
||||
* @returns 用户Id
|
||||
*/
|
||||
private getUserId(body: LarkEvent.Data) {
|
||||
return body?.event?.sender?.sender_id?.user_id
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户OpenId
|
||||
* @param body 事件消息体
|
||||
* @returns 用户OpenId
|
||||
*/
|
||||
private getOpenId(body: LarkEvent.Data) {
|
||||
return body?.event?.sender?.sender_id?.open_id
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文本内容并剔除艾特信息
|
||||
* @param body 事件消息体
|
||||
@ -299,6 +281,28 @@ class LarkBody {
|
||||
return ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户Id
|
||||
* @param body 事件消息体
|
||||
* @returns 用户Id
|
||||
*/
|
||||
private getUserId(body: LarkEvent.Data | LarkAction.Data) {
|
||||
if (this.getIsEvent(body)) return body?.event?.sender?.sender_id?.user_id
|
||||
if (this.getIsAction(body)) return body?.user_id
|
||||
return ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户OpenId
|
||||
* @param body 事件消息体
|
||||
* @returns 用户OpenId
|
||||
*/
|
||||
private getOpenId(body: LarkEvent.Data | LarkAction.Data) {
|
||||
if (this.getIsEvent(body)) return body?.event?.sender?.sender_id?.open_id
|
||||
if (this.getIsAction(body)) return body?.open_id
|
||||
return ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否艾特了机器人
|
||||
* @param name 机器人名字
|
||||
|
Loading…
x
Reference in New Issue
Block a user