Compare commits
2 Commits
@egg/lark-
...
@egg/lark-
Author | SHA1 | Date | |
---|---|---|---|
8620752a46 | |||
2c11ce4841 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -12258,7 +12258,7 @@
|
||||
},
|
||||
"packages/lark-msg-tool": {
|
||||
"name": "@egg/lark-msg-tool",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"license": "ISC"
|
||||
},
|
||||
"packages/logger": {
|
||||
|
@ -3,6 +3,10 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.3.1](http://yingbo.im:3000/zhaoyingbo/egg_tools/compare/@egg/lark-msg-tool@1.3.0...@egg/lark-msg-tool@1.3.1) (2024-09-26)
|
||||
|
||||
**Note:** Version bump only for package @egg/lark-msg-tool
|
||||
|
||||
# 1.3.0 (2024-09-26)
|
||||
|
||||
### Features
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@egg/lark-msg-tool",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"description": "Lark Msg Tools for Egg projects",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
|
@ -5,7 +5,7 @@ import { LarkAction, LarkEvent } from "./types"
|
||||
* @param body 事件消息体
|
||||
* @returns 是否为事件消息
|
||||
*/
|
||||
export const getIsEventMsg = (body: LarkEvent.Data) => {
|
||||
export const getIsEventMsg = (body: any): body is LarkEvent.Data => {
|
||||
return body?.header?.event_type === "im.message.receive_v1"
|
||||
}
|
||||
|
||||
@ -18,15 +18,6 @@ export const getMsgType = (body: LarkEvent.Data) => {
|
||||
return body?.event?.message?.message_type
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对话流Id
|
||||
* @param body 事件消息体
|
||||
* @returns 对话流Id
|
||||
*/
|
||||
export const getChatId = (body: LarkEvent.Data & LarkAction.Data) => {
|
||||
return body?.event?.message?.chat_id || body?.open_chat_id
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户Id
|
||||
* @param body 事件消息体
|
||||
@ -75,7 +66,7 @@ export const getMentions = (body: LarkEvent.Data) => {
|
||||
* @param body Action消息体
|
||||
* @returns 是否为Action消息
|
||||
*/
|
||||
export const getIsActionMsg = (body: LarkAction.Data) => {
|
||||
export const getIsActionMsg = (body: any): body is LarkAction.Data => {
|
||||
return !!body?.action
|
||||
}
|
||||
|
||||
@ -106,4 +97,15 @@ export const getActionOption = (body: LarkAction.Data) => {
|
||||
return body?.action?.option
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对话流Id
|
||||
* @param body 事件消息体
|
||||
* @returns 对话流Id
|
||||
*/
|
||||
export const getChatId = (body: LarkEvent.Data | LarkAction.Data) => {
|
||||
if (getIsEventMsg(body)) return body?.event?.message?.chat_id
|
||||
if (getIsActionMsg(body)) return body?.open_chat_id
|
||||
return ""
|
||||
}
|
||||
|
||||
export { LarkAction, LarkEvent }
|
||||
|
Loading…
x
Reference in New Issue
Block a user