forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommunications.go
54 lines (44 loc) · 1.44 KB
/
communications.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
package communications
import (
"errors"
"github.com/thrasher-corp/gocryptotrader/communications/base"
"github.com/thrasher-corp/gocryptotrader/communications/slack"
"github.com/thrasher-corp/gocryptotrader/communications/smsglobal"
"github.com/thrasher-corp/gocryptotrader/communications/smtpservice"
"github.com/thrasher-corp/gocryptotrader/communications/telegram"
)
// Communications is the overarching type across the communications packages
type Communications struct {
base.IComm
}
// ErrNoCommunicationRelayersEnabled returns when no relayers enabled
var ErrNoCommunicationRelayersEnabled = errors.New("no communication relayers enabled")
// NewComm sets up and returns a pointer to a Communications object
func NewComm(cfg *base.CommunicationsConfig) (*Communications, error) {
if !cfg.IsAnyEnabled() {
return nil, ErrNoCommunicationRelayersEnabled
}
var comm Communications
if cfg.TelegramConfig.Enabled {
Telegram := new(telegram.Telegram)
Telegram.Setup(cfg)
comm.IComm = append(comm.IComm, Telegram)
}
if cfg.SMSGlobalConfig.Enabled {
SMSGlobal := new(smsglobal.SMSGlobal)
SMSGlobal.Setup(cfg)
comm.IComm = append(comm.IComm, SMSGlobal)
}
if cfg.SMTPConfig.Enabled {
SMTP := new(smtpservice.SMTPservice)
SMTP.Setup(cfg)
comm.IComm = append(comm.IComm, SMTP)
}
if cfg.SlackConfig.Enabled {
Slack := new(slack.Slack)
Slack.Setup(cfg)
comm.IComm = append(comm.IComm, Slack)
}
comm.Setup()
return &comm, nil
}