commit a16c4c4f97e7a2a0a687ade7b30d66ed0604d3bb
Author: Wim <wim@42.be>
Date: Mon Aug 15 23:15:22 2016 +0000
diff --git a/bridge/bridge.go b/bridge/bridge.go
index 8fe233d..a849ba6 100644
--- a/bridge/bridge.go
+++ b/bridge/bridge.go
@@ -1447 +1433 @@ 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)
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 131ff95..03836b6 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -266 +267 @@ type Config struct {
NickServPassword string
RemoteNickFormat string
IgnoreNicks string
+ Enable bool
}
Mattermost struct {
URL string
@@ -446 +457 @@ type Config struct {
RemoteNickFormat string
IgnoreNicks string
NoTLS bool
+ Enable bool
}
Xmpp struct {
Jid string
@@ -526 +547 @@ type Config struct {
Muc string
Nick string
RemoteNickFormat string
+ Enable bool
}
Channel map[string]*struct {
IRC string
diff --git a/matterbridge.conf.sample b/matterbridge.conf.sample
index f8f07f7..43d69a5 100644
--- a/matterbridge.conf.sample
+++ b/matterbridge.conf.sample
@@ -36 +39 @@
#IRC section
###################################################################
[IRC]
+#Enable enables this bridge
+#OPTIONAL (default false)
+Enable=true
#irc server to connect to.
#REQUIRED
Server="irc.freenode.net:6667"
@@ -456 +4810 @@ IgnoreNicks="ircspammer1 ircspammer2"
#XMPP section
###################################################################
[XMPP]
+#Enable enables this bridge
+#OPTIONAL (default false)
+Enable=true
+
#xmpp server to connect to.
#REQUIRED
Server="jabber.example.com:5222"
@@ -716 +7810 @@ Nick="xmppbot"
###################################################################
[mattermost]
+#Enable enables this bridge
+#OPTIONAL (default false)
+Enable=true
+
#### Settings for webhook matterbridge.
#### These settings will not be used when using -plus switch which doesn't use
#### webhooks.
@@ -1749 +1853 @@ GiphyApiKey="dc6zaTOxFJmzC"
#Enabling plus means you'll use the API version instead of the webhooks one
Plus=false
-
-#Choose protocols to bridge. You need to specify at least two
-#REQUIRED
-Irc=true
-Xmpp=false
-Mattermost=true