forked from shomali11/slacker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
defaults.go
55 lines (44 loc) · 1.09 KB
/
defaults.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
package slacker
import "github.com/nlopes/slack"
// ClientOption an option for client values
type ClientOption func(*ClientDefaults)
// WithDebug sets debug toggle
func WithDebug(debug bool) ClientOption {
return func(defaults *ClientDefaults) {
defaults.Debug = debug
}
}
// ClientDefaults configuration
type ClientDefaults struct {
Debug bool
}
func newClientDefaults(options ...ClientOption) *ClientDefaults {
config := &ClientDefaults{
Debug: false,
}
for _, option := range options {
option(config)
}
return config
}
// ReplyOption an option for reply values
type ReplyOption func(*ReplyDefaults)
// WithAttachments sets message attachments
func WithAttachments(attachments []slack.Attachment) ReplyOption {
return func(defaults *ReplyDefaults) {
defaults.Attachments = attachments
}
}
// ReplyDefaults configuration
type ReplyDefaults struct {
Attachments []slack.Attachment
}
func newReplyDefaults(options ...ReplyOption) *ReplyDefaults {
config := &ReplyDefaults{
Attachments: []slack.Attachment{},
}
for _, option := range options {
option(config)
}
return config
}