chore(lark-msg): 删除无用类型注释
All checks were successful
/ release (push) Successful in 23s

This commit is contained in:
zhaoyingbo 2024-09-24 03:30:05 +00:00
parent 6d47652aa3
commit ee271ed4cc
2 changed files with 38 additions and 28 deletions

View File

@ -2,64 +2,64 @@ import { LarkAction, LarkEvent } from "./types"
/**
*
* @param {LarkEvent.Data} body -
* @returns {boolean}
* @param body
* @returns
*/
export const getIsEventMsg = (body: LarkEvent.Data): boolean => {
export const getIsEventMsg = (body: LarkEvent.Data) => {
return body?.header?.event_type === "im.message.receive_v1"
}
/**
*
* @param {LarkEvent.Data} body -
* @returns {string | undefined}
* @param body
* @returns
*/
export const getMsgType = (body: LarkEvent.Data): string | undefined => {
export const getMsgType = (body: LarkEvent.Data) => {
return body?.event?.message?.message_type
}
/**
* Id
* @param {LarkEvent.Data} body -
* @returns {string | undefined} Id
* @param body
* @returns Id
*/
export const getChatId = (body: LarkEvent.Data): string | undefined => {
export const getChatId = (body: LarkEvent.Data) => {
return body?.event?.message?.chat_id
}
/**
* Id
* @param {LarkEvent.Data} body -
* @returns {string | undefined} Id
* @param body
* @returns Id
*/
export const getUserId = (body: LarkEvent.Data): string | undefined => {
export const getUserId = (body: LarkEvent.Data) => {
return body?.event?.sender?.sender_id?.user_id
}
/**
* Action消息
* @param {LarkAction.Data} body - Action消息体
* @returns {boolean} Action消息
* @param body Action消息体
* @returns Action消息
*/
export const getIsActionMsg = (body: LarkAction.Data): boolean => {
export const getIsActionMsg = (body: LarkAction.Data) => {
return !!body?.action
}
/**
* Action类型
* @param {LarkAction.Data} body - Action消息体
* @returns {string | undefined} Action类型
* @param body Action消息体
* @returns Action类型
*/
export const getActionType = (body: LarkAction.Data): string | undefined => {
export const getActionType = (body: LarkAction.Data) => {
return body?.action?.tag
}
/**
*
* @param {LarkEvent.Data} body -
* @returns {string}
* @param body
* @returns
*/
export const getMsgText = (body: LarkEvent.Data): string => {
export const getMsgText = (body: LarkEvent.Data) => {
try {
const { text }: { text: string } = JSON.parse(body?.event?.message?.content)
// 去掉@_user_1相关的内容例如 '@_user_1 测试' -> '测试'
@ -72,19 +72,19 @@ export const getMsgText = (body: LarkEvent.Data): string => {
/**
*
* @param {LarkEvent.Data} body -
* @returns {string | undefined}
* @param body
* @returns
*/
export const getChatType = (body: LarkEvent.Data): string | undefined => {
export const getChatType = (body: LarkEvent.Data) => {
return body?.event?.message?.chat_type
}
/**
*
* @param {LarkEvent.Data} body -
* @returns {Array | undefined}
* @param body
* @returns
*/
export const getMentions = (body: LarkEvent.Data): Array<any> | undefined => {
export const getMentions = (body: LarkEvent.Data) => {
return body?.event?.message?.mentions
}

View File

@ -95,7 +95,17 @@ export namespace LarkEvent {
*
* @example textpostimagefileaudiomediastickerinteractiveshare_chatshare_user
*/
message_type: string
message_type:
| "text"
| "post"
| "image"
| "file"
| "audio"
| "media"
| "sticker"
| "interactive"
| "share_chat"
| "share_user"
}
/**