Compare commits

...

2 Commits

Author SHA1 Message Date
8620752a46 chore(release): publish
- @egg/lark-msg-tool@1.3.1
2024-09-26 01:42:10 +00:00
2c11ce4841 chore(lark-msg): 优化getChatId函数实现
All checks were successful
/ release (push) Successful in 24s
2024-09-26 01:41:45 +00:00
4 changed files with 19 additions and 13 deletions

2
package-lock.json generated
View File

@ -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": {

View File

@ -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

View File

@ -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",

View File

@ -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 }