-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
slack.go
50 lines (43 loc) · 1.4 KB
/
slack.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
package slackstatus
type field struct {
Title string `json:"title"`
Value string `json:"value"`
Short bool `json:"short"`
}
type attachment struct {
Fallback *string `json:"fallback"`
Color *string `json:"color"`
PreText *string `json:"pretext"`
AuthorName *string `json:"author_name"`
AuthorLink *string `json:"author_link"`
AuthorIcon *string `json:"author_icon"`
Title *string `json:"title"`
TitleLink *string `json:"title_link"`
Text *string `json:"text"`
ImageURL *string `json:"image_url"`
Fields []*field `json:"fields"`
Footer *string `json:"footer"`
FooterIcon *string `json:"footer_icon"`
}
type payload struct {
Parse string `json:"parse,omitempty"`
Username string `json:"username,omitempty"`
IconURL string `json:"icon_url,omitempty"`
IconEmoji string `json:"icon_emoji,omitempty"`
Channel string `json:"channel,omitempty"`
Text string `json:"text,omitempty"`
Attachments []attachment `json:"attachments,omitempty"`
}
func composeMessage(slackmessage *Message, text string, color string) payload {
slackAttachment := attachment{
Color: &color,
Text: &text,
Footer: &slackmessage.Footer,
}
return payload{
Username: slackmessage.Username,
IconEmoji: slackmessage.IconEmoji,
Channel: slackmessage.Channel,
Attachments: []attachment{slackAttachment},
}
}