-
Notifications
You must be signed in to change notification settings - Fork 1
/
notificator.go
66 lines (54 loc) · 1.48 KB
/
notificator.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
57
58
59
60
61
62
63
64
65
66
package tob
import (
"github.com/telkomdev/tob/config"
"github.com/telkomdev/tob/notificators/discord"
"github.com/telkomdev/tob/notificators/email"
"github.com/telkomdev/tob/notificators/slack"
"github.com/telkomdev/tob/notificators/telegram"
"github.com/telkomdev/tob/notificators/webhook"
)
// Notificator the notificator base
type Notificator interface {
// Provider will return Notificator provider
Provider() string
// Send will send message to Notificator
Send(msg string) error
// IsEnabled will return enable status
IsEnabled() bool
}
// InitNotificatorFactory will init all notificator
func InitNotificatorFactory(configs config.Config, verbose bool) []Notificator {
// discord notificator
discordNotificator, err := discord.NewDiscord(configs, verbose, Logger)
if err != nil {
discordNotificator = nil
}
// email notificator
emailNotificator, err := email.NewEmail(configs)
if err != nil {
emailNotificator = nil
}
// slack notificator
slackNotificator, err := slack.NewSlack(configs)
if err != nil {
slackNotificator = nil
}
// telegram notificator
telegramNotificator, err := telegram.NewTelegram(configs)
if err != nil {
telegramNotificator = nil
}
// webhook notificator
webhookNotificator, err := webhook.NewWebhook(configs, verbose, Logger)
if err != nil {
webhookNotificator = nil
}
notificators := []Notificator{
emailNotificator,
discordNotificator,
slackNotificator,
telegramNotificator,
webhookNotificator,
}
return notificators
}