-
Notifications
You must be signed in to change notification settings - Fork 47
/
message.go
53 lines (45 loc) · 1.78 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
/*
Copyright (c) 2021 - Present. Blend Labs, Inc. All rights reserved
Blend Confidential - Restricted
*/
package slack
// NewMessage creates a new message with a given set of options.
func NewMessage(options ...MessageOption) *Message {
var m Message
for _, option := range options {
option(&m)
}
return &m
}
// Message is a message sent to slack.
type Message struct {
Username string `json:"username,omitempty"`
Channel string `json:"channel,omitempty"`
Parse string `json:"parse,omitempty"`
ResponseType string `json:"response_type,omitempty"`
Text string `json:"text"`
IconEmoji string `json:"icon_emoji,omitempty"`
IconURL string `json:"icon_url,omitempty"`
ThreadTimestamp string `json:"thread_ts,omitempty"`
Attachments []MessageAttachment `json:"attachments"`
// Response-specific fields
BotID string `json:"bot_id,omitempty"`
Type string `json:"type,omitempty"`
SubType string `json:"subtype,omitempty"`
Timestamp string `json:"ts,omitempty"`
}
// MessageAttachment is an attachment for a message.
type MessageAttachment struct {
Title string `json:"title,omitempty"`
Color string `json:"color,omitempty"`
Pretext string `json:"pretext,omitempty"`
Text string `json:"text,omitempty"`
MarkdownIn []string `json:"mrkdwn_in,omitempty"`
Fields []MessageAttachmentField `json:"fields,omitempty"`
}
// MessageAttachmentField is a field on an attachment.
type MessageAttachmentField struct {
Title string `json:"title,omitempty"`
Value string `json:"value,omitempty"`
Short bool `json:"short"`
}