commit 6d50f4fa2e8e237966a4dedf5a5d187db513244e
Author: Wim <wim@42.be>
Date: Mon Sep 19 23:05:49 2016 +0000
diff --git a/gateway/gateway.go b/gateway/gateway.go
index 6ac36d4..e1131f1 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -2315 +2327 @@ func New(cfg *config.Config, gateway *config.Gateway) error {
gw.Name = gateway.Name
gw.Config = cfg
gw.MyConfig = gateway
- for _, br := range gateway.In {
+ exists := make(map[string]bool)
+ for _, br := range append(gateway.In, gateway.Out...) {
+ if exists[br.Account+br.Channel] {
+ continue
+ }
+ log.Infof("Starting bridge: %s channel: %s", br.Account, br.Channel)
gw.Bridges = append(gw.Bridges, bridge.New(cfg, &br, c))
+ exists[br.Account+br.Channel] = true
}
gw.mapChannels()
gw.mapIgnores()
+ exists = make(map[string]bool)
for _, br := range gw.Bridges {
br.Connect()
- for _, channel := range gw.ChannelsOut[br.FullOrigin()] {
+ for _, channel := range append(gw.ChannelsOut[br.FullOrigin()], gw.ChannelsIn[br.FullOrigin()]...) {
+ if exists[br.FullOrigin()+channel] {
+ continue
+ }
+ log.Infof("%s: joining %s", br.FullOrigin(), channel)
br.JoinChannel(channel)
+ exists[br.FullOrigin()+channel] = true
}
}
gw.handleReceive(c)
@@ -857 +976 @@ func (gw *Gateway) handleMessage(msg config.Message, dest bridge.Bridge) {
for _, channel := range channels {
// do not send the message to the bridge we come from if also the channel is the same
if msg.FullOrigin == dest.FullOrigin() && msg.Channel == channel {
- log.Debug("continue", msg.Protocol, msg.Origin, dest.Protocol(), dest.Origin())
continue
}
msg.Channel = channel