feat(lark-msg-tool): 重构用户Id和OpenId获取方法以支持事件和动作消息体
All checks were successful
/ release (push) Successful in 25s
All checks were successful
/ release (push) Successful in 25s
This commit is contained in:
parent
404d45842a
commit
fc8399e10b
@ -101,8 +101,6 @@ class LarkBody {
|
|||||||
this.eventType = this.getEventType(eventBody)
|
this.eventType = this.getEventType(eventBody)
|
||||||
this.isMessageEvent = this.getIsMessageEvent(eventBody)
|
this.isMessageEvent = this.getIsMessageEvent(eventBody)
|
||||||
this.msgType = this.getMsgType(eventBody)
|
this.msgType = this.getMsgType(eventBody)
|
||||||
this.userId = this.getUserId(eventBody)
|
|
||||||
this.openId = this.getOpenId(eventBody)
|
|
||||||
this.msgText = this.getMsgText(eventBody)
|
this.msgText = this.getMsgText(eventBody)
|
||||||
this.rawMsgText = this.getRawMsgText(eventBody)
|
this.rawMsgText = this.getRawMsgText(eventBody)
|
||||||
this.chatType = this.getChatType(eventBody)
|
this.chatType = this.getChatType(eventBody)
|
||||||
@ -121,6 +119,8 @@ class LarkBody {
|
|||||||
|
|
||||||
this.chatId = this.getChatId(body)
|
this.chatId = this.getChatId(body)
|
||||||
this.messageId = this.getMessageId(body)
|
this.messageId = this.getMessageId(body)
|
||||||
|
this.userId = this.getUserId(body)
|
||||||
|
this.openId = this.getOpenId(body)
|
||||||
this.isLarkBody = this.isEvent || this.isAction
|
this.isLarkBody = this.isEvent || this.isAction
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,24 +169,6 @@ class LarkBody {
|
|||||||
return body?.event?.message?.message_type
|
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 事件消息体
|
* @param body 事件消息体
|
||||||
@ -299,6 +281,28 @@ class LarkBody {
|
|||||||
return ""
|
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 机器人名字
|
* @param name 机器人名字
|
||||||
|
Loading…
x
Reference in New Issue
Block a user