diff options
Diffstat (limited to 'gateway/gateway.go')
-rw-r--r-- | gateway/gateway.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gateway/gateway.go b/gateway/gateway.go index 19571776..95bf902a 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -40,10 +40,8 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error { } log.Infof("Starting bridge: %s ", cfg.Account) br := bridge.New(gw.Config, cfg, gw.Message) - br.ChannelsOut = gw.ChannelsOut[br.Account] - br.ChannelsIn = gw.ChannelsIn[br.Account] - br.ChannelOptions = gw.ChannelOptions[br.Account] - + gw.mapChannelsToBridge(br, gw.ChannelsOut) + gw.mapChannelsToBridge(br, gw.ChannelsIn) gw.Bridges[cfg.Account] = br err := br.Connect() if err != nil { @@ -53,6 +51,16 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error { return nil } +func (gw *Gateway) mapChannelsToBridge(br *bridge.Bridge, cMap map[string][]string) { + for _, channel := range cMap[br.Account] { + if _, ok := gw.ChannelOptions[br.Account+channel]; ok { + br.ChannelsOut[channel] = gw.ChannelOptions[br.Account+channel] + } else { + br.ChannelsOut[channel] = config.ChannelOptions{} + } + } +} + func (gw *Gateway) Start() error { gw.mapChannels() for _, br := range append(gw.MyConfig.In, append(gw.MyConfig.InOut, gw.MyConfig.Out...)...) { |