forked from go-lark/lark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.go
99 lines (87 loc) · 2.53 KB
/
message.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package lark
// Msg Types
const (
MsgText = "text"
MsgPost = "post"
MsgInteractive = "interactive"
MsgImage = "image"
MsgShareCard = "share_chat"
MsgShareUser = "share_user"
MsgAudio = "audio"
MsgMedia = "media"
MsgFile = "file"
MsgSticker = "sticker"
)
// OutcomingMessage struct of an outcoming message
type OutcomingMessage struct {
MsgType string `json:"msg_type"`
Content MessageContent `json:"content"`
Card CardContent `json:"card"`
// ID for user
UIDType string `json:"-"`
OpenID string `json:"open_id,omitempty"`
Email string `json:"email,omitempty"`
UserID string `json:"user_id,omitempty"`
ChatID string `json:"chat_id,omitempty"`
UnionID string `json:"-"`
// For reply
RootID string `json:"root_id,omitempty"`
ReplyInThread bool `json:"reply_in_thread,omitempty"`
// Sign for notification bot
Sign string `json:"sign"`
// Timestamp for sign
Timestamp int64 `json:"timestamp"`
// UUID for idempotency
UUID string `json:"uuid"`
}
// CardContent struct of card content
type CardContent map[string]interface{}
// MessageContent struct of message content
type MessageContent struct {
Text *TextContent `json:"text,omitempty"`
Image *ImageContent `json:"image,omitempty"`
Post *PostContent `json:"post,omitempty"`
Card *CardContent `json:"card,omitempty"`
ShareChat *ShareChatContent `json:"share_chat,omitempty"`
ShareUser *ShareUserContent `json:"share_user,omitempty"`
Audio *AudioContent `json:"audio,omitempty"`
Media *MediaContent `json:"media,omitempty"`
File *FileContent `json:"file,omitempty"`
Sticker *StickerContent `json:"sticker,omitempty"`
}
// TextContent .
type TextContent struct {
Text string `json:"text"`
}
// ImageContent .
type ImageContent struct {
ImageKey string `json:"image_key"`
}
// ShareChatContent .
type ShareChatContent struct {
ChatID string `json:"chat_id"`
}
// ShareUserContent .
type ShareUserContent struct {
UserID string `json:"user_id"`
}
// AudioContent .
type AudioContent struct {
FileKey string `json:"file_key"`
}
// MediaContent .
type MediaContent struct {
FileName string `json:"file_name,omitempty"`
FileKey string `json:"file_key"`
ImageKey string `json:"image_key"`
Duration int `json:"duration,omitempty"`
}
// FileContent .
type FileContent struct {
FileName string `json:"file_name,omitempty"`
FileKey string `json:"file_key"`
}
// StickerContent .
type StickerContent struct {
FileKey string `json:"file_key"`
}