-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
56 lines (49 loc) · 1.14 KB
/
options.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
package notifier
import (
"github.com/moond4rk/notifier/provider/bark"
"github.com/moond4rk/notifier/provider/dingtalk"
"github.com/moond4rk/notifier/provider/feishu"
"github.com/moond4rk/notifier/provider/lark"
"github.com/moond4rk/notifier/provider/serverchan"
)
type Option func(p *Notifier)
func WithDingTalk(token, secret string) Option {
d := dingtalk.New(token, secret)
return func(n *Notifier) {
if d != nil {
n.Providers = append(n.Providers, d)
}
}
}
func WithBark(key, server string) Option {
b := bark.New(key, server)
return func(n *Notifier) {
if b != nil {
n.Providers = append(n.Providers, b)
}
}
}
func WithLark(token, secret string) Option {
l := lark.New(token, secret)
return func(n *Notifier) {
if l != nil {
n.Providers = append(n.Providers, l)
}
}
}
func WithFeishu(token, secret string) Option {
l := feishu.New(token, secret)
return func(n *Notifier) {
if l != nil {
n.Providers = append(n.Providers, l)
}
}
}
func WithServerChan(userID, sendKey string) Option {
s := serverchan.New(userID, sendKey)
return func(n *Notifier) {
if s != nil {
n.Providers = append(n.Providers, s)
}
}
}