diff options
author | Wim <wim@42.be> | 2017-04-01 17:24:19 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-04-01 17:24:19 +0200 |
commit | a16ad8bf3b39d99658f306d3c065680c606e4801 (patch) | |
tree | 370528dd84572928161f4eff988f738581394ac0 /bridge/bridge.go | |
parent | 1e0490bd36ec20a7de43587f43feb6ec63c02ddb (diff) | |
download | matterbridge-msglm-a16ad8bf3b39d99658f306d3c065680c606e4801.tar.gz matterbridge-msglm-a16ad8bf3b39d99658f306d3c065680c606e4801.tar.bz2 matterbridge-msglm-a16ad8bf3b39d99658f306d3c065680c606e4801.zip |
Reuse connection when using same bridge with another gateway. See #87
Diffstat (limited to 'bridge/bridge.go')
-rw-r--r-- | bridge/bridge.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bridge/bridge.go b/bridge/bridge.go index 022e6a98..1d377951 100644 --- a/bridge/bridge.go +++ b/bridge/bridge.go @@ -31,6 +31,7 @@ type Bridge struct { Account string Protocol string Channels map[string]config.ChannelInfo + Joined map[string]bool } func New(cfg *config.Config, bridge *config.Bridge, c chan config.Message) *Bridge { @@ -42,6 +43,7 @@ func New(cfg *config.Config, bridge *config.Bridge, c chan config.Message) *Brid b.Name = name b.Protocol = protocol b.Account = bridge.Account + b.Joined = make(map[string]bool) // override config from environment config.OverrideCfgFromEnv(cfg, protocol, name) @@ -81,8 +83,7 @@ func New(cfg *config.Config, bridge *config.Bridge, c chan config.Message) *Brid } func (b *Bridge) JoinChannels() error { - exists := make(map[string]bool) - err := b.joinChannels(b.Channels, exists) + err := b.joinChannels(b.Channels, b.Joined) if err != nil { return err } @@ -94,7 +95,7 @@ func (b *Bridge) joinChannels(channels map[string]config.ChannelInfo, exists map for ID, channel := range channels { if !exists[ID] { mychannel = channel.Name - log.Infof("%s: joining %s %s", b.Account, channel.Name, ID) + log.Infof("%s: joining %s (%s)", b.Account, channel.Name, ID) if b.Protocol == "irc" && channel.Options.Key != "" { log.Debugf("using key %s for channel %s", channel.Options.Key, channel.Name) mychannel = mychannel + " " + channel.Options.Key |