forked from go-lark/lark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_v1.go
32 lines (31 loc) · 931 Bytes
/
message_v1.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package lark
// BuildOutcomingMessageReq for msg builder
func BuildOutcomingMessageReq(om OutcomingMessage) map[string]interface{} {
params := map[string]interface{}{
"msg_type": om.MsgType,
"update_multi": om.UpdateMulti,
"chat_id": om.ChatID, // request must contain chat_id, even if it is empty
}
params[om.UIDType] = buildReceiveID(om)
if len(om.RootID) > 0 {
params["root_id"] = om.RootID
}
content := make(map[string]interface{})
if om.Content.Text != nil {
content["text"] = om.Content.Text.Text
}
if om.Content.Image != nil {
content["image_key"] = om.Content.Image.ImageKey
}
if om.Content.ShareChat != nil {
content["share_open_chat_id"] = om.Content.ShareChat.ChatID
}
if om.Content.Post != nil {
content["post"] = *om.Content.Post
}
if om.MsgType == MsgInteractive && om.Content.Card != nil {
params["card"] = *om.Content.Card
}
params["content"] = content
return params
}