feat(lark-msg): 支持获取原始text
All checks were successful
/ release (push) Successful in 24s

This commit is contained in:
zhaoyingbo 2024-10-15 07:32:31 +00:00
parent fc84a87004
commit 23e7404902

View File

@ -7,6 +7,7 @@ class LarkBody {
public msgType?: LarkEvent.Message["message_type"]
public userId?: LarkEvent.UserIdInfo["user_id"]
public msgText: string = ""
public rawMsgText: string = ""
public chatType?: LarkEvent.Message["chat_type"]
public mentions?: LarkEvent.Mention[]
public actionType?: LarkAction.Data["action"]["tag"]
@ -33,6 +34,7 @@ class LarkBody {
this.msgType = this.getMsgType(eventBody)
this.userId = this.getUserId(eventBody)
this.msgText = this.getMsgText(eventBody)
this.rawMsgText = this.getRawMsgText(eventBody)
this.chatType = this.getChatType(eventBody)
this.mentions = this.getMentions(eventBody)
}
@ -102,6 +104,22 @@ class LarkBody {
}
}
/**
*
* @param body
* @returns
*/
private getRawMsgText(body: LarkEvent.Data) {
try {
const { text }: { text: string } = JSON.parse(
body?.event?.message?.content
)
return text
} catch {
return ""
}
}
/**
*
* @param body