-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessage.go
More file actions
72 lines (58 loc) · 1.58 KB
/
message.go
File metadata and controls
72 lines (58 loc) · 1.58 KB
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
package botclient
type msg struct {
MessageType string `json:"msgtype"`
Text Message `json:"text,omitempty"`
Markdown Message `json:"markdown,omitempty"`
Image Message `json:"image,omitempty"`
News Message `json:"news,omitempty"`
File Message `json:"file,omitempty"`
TemplateCard Message `json:"template_card,omitempty"`
}
type Message interface {
GetType() string
}
type TextMessage struct {
Content string `json:"content"`
MentionedList []string `json:"mentioned_list,omitempty"`
MentionedMobileList []string `json:"mentioned_mobile_list,omitempty"`
}
func (text *TextMessage) GetType() string {
return Text
}
type MarkdownMessage struct {
Content string `json:"content"`
}
func (markdown *MarkdownMessage) GetType() string {
return Markdown
}
type ImageMessage struct {
Base64 string `json:"base64"`
Md5 string `json:"md5"`
}
func (image *ImageMessage) GetType() string {
return Image
}
type NewsMessage struct {
Articles []NewsMessageArticle `json:"articles"`
}
type NewsMessageArticle struct {
Title string `json:"title"`
Description string `json:"description"`
URL string `json:"url"`
PicURL string `json:"picurl"`
}
func (news *NewsMessage) GetType() string {
return News
}
func (news *NewsMessage) AddArticle(article ...NewsMessageArticle) {
if news.Articles == nil {
news.Articles = make([]NewsMessageArticle, 0)
}
news.Articles = append(news.Articles, article...)
}
type FileMessage struct {
MediaId string `json:"media_id"`
}
func (file *FileMessage) GetType() string {
return File
}