summaryrefslogtreecommitdiffstats
path: root/bridge/bridge.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-08-15 23:15:22 +0200
committerWim <wim@42.be>2016-08-20 18:08:57 +0200
commit9cb3413d9c79730fc3b61bfdef6b2c9a2003a383 (patch)
treeacf61c7e0ba2908e8956dfba4392d19a75727b93 /bridge/bridge.go
parent131826e1d138a98066813faa284da377bb99ecbe (diff)
downloadmatterbridge-msglm-9cb3413d9c79730fc3b61bfdef6b2c9a2003a383.tar.gz
matterbridge-msglm-9cb3413d9c79730fc3b61bfdef6b2c9a2003a383.tar.bz2
matterbridge-msglm-9cb3413d9c79730fc3b61bfdef6b2c9a2003a383.zip
Add Enable per section (protocol) instead of in general section
Diffstat (limited to 'bridge/bridge.go')
-rw-r--r--bridge/bridge.go28
1 files changed, 7 insertions, 21 deletions
diff --git a/bridge/bridge.go b/bridge/bridge.go
index 8fe233d6..a849ba67 100644
--- a/bridge/bridge.go
+++ b/bridge/bridge.go
@@ -14,47 +14,33 @@ type Bridge struct {
*config.Config
Source string
Bridges []Bridger
- kind string
Channels []map[string]string
ignoreNicks map[string][]string
}
-type FancyLog struct {
- irc *log.Entry
- mm *log.Entry
- xmpp *log.Entry
-}
-
type Bridger interface {
Send(msg config.Message) error
Name() string
+ Connect() error
//Command(cmd string) string
}
-var flog FancyLog
-
-const Legacy = "legacy"
-
-func initFLog() {
- flog.irc = log.WithFields(log.Fields{"module": "irc"})
- flog.mm = log.WithFields(log.Fields{"module": "mattermost"})
- flog.xmpp = log.WithFields(log.Fields{"module": "xmpp"})
-}
-
func NewBridge(cfg *config.Config) error {
c := make(chan config.Message)
- initFLog()
b := &Bridge{}
b.Config = cfg
- if cfg.General.Irc {
+ if cfg.IRC.Enable {
b.Bridges = append(b.Bridges, birc.New(cfg, c))
}
- if cfg.General.Mattermost {
+ if cfg.Mattermost.Enable {
b.Bridges = append(b.Bridges, bmattermost.New(cfg, c))
}
- if cfg.General.Xmpp {
+ if cfg.Xmpp.Enable {
b.Bridges = append(b.Bridges, bxmpp.New(cfg, c))
}
+ if len(b.Bridges) < 2 {
+ log.Fatalf("only %d sections enabled. Need at least 2 sections enabled (eg [IRC] and [mattermost]", len(b.Bridges))
+ }
b.mapChannels()
b.mapIgnores()
b.handleReceive(c)