From e0e1e4be8018b256d86e2df9c3f84fc7881041c3 Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 20 Nov 2016 23:01:44 +0100 Subject: [PATCH] Add gateway.inout config for bidirectional bridges. Closes #85 --- bridge/config/config.go | 1 + gateway/gateway.go | 6 +++++- matterbridge.toml.sample | 10 +++++----- matterbridge.toml.simple | 6 +----- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/bridge/config/config.go b/bridge/config/config.go index 5fed2f0a..1958bf57 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -62,6 +62,7 @@ type Gateway struct { Enable bool In []Bridge Out []Bridge + InOut []Bridge } type SameChannelGateway struct { diff --git a/gateway/gateway.go b/gateway/gateway.go index 63da4bba..f45f315e 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -57,7 +57,7 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error { func (gw *Gateway) Start() error { gw.mapChannels() - for _, br := range append(gw.MyConfig.In, gw.MyConfig.Out...) { + for _, br := range append(gw.MyConfig.In, append(gw.MyConfig.InOut, gw.MyConfig.Out...)...) { err := gw.AddBridge(&br) if err != nil { return err @@ -92,6 +92,10 @@ func (gw *Gateway) mapChannels() error { m[br.Account] = append(m[br.Account], br.Channel) } gw.ChannelsIn = m + for _, br := range gw.MyConfig.InOut { + gw.ChannelsIn[br.Account] = append(gw.ChannelsIn[br.Account], br.Channel) + gw.ChannelsOut[br.Account] = append(gw.ChannelsOut[br.Account], br.Channel) + } return nil } diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 2e5f8186..df73713b 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -383,7 +383,7 @@ ShowJoinPart=false #from [[gateway.in]] to. # #Most of the time [[gateway.in]] and [[gateway.out]] are the same if you -#want bidirectional bridging. +#want bidirectional bridging. You can then use [[gateway.inout]] # [[gateway]] @@ -415,15 +415,15 @@ enable=true #REQUIRED channel="#testing" - [[gateway.in]] - account="mattermost.work" - channel="off-topic" + #[[gateway.out]] specifies the account and channels we will sent messages to. [[gateway.out]] account="irc.freenode" channel="#testing" - [[gateway.out]] + #[[gateway.inout]] can be used when then channel will be used to receive from + #and send messages to + [[gateway.inout]] account="mattermost.work" channel="off-topic" diff --git a/matterbridge.toml.simple b/matterbridge.toml.simple index 30104d98..d39a33f4 100644 --- a/matterbridge.toml.simple +++ b/matterbridge.toml.simple @@ -19,14 +19,10 @@ enable=true account="irc.freenode" channel="#testing" - [[gateway.in]] - account="mattermost.work" - channel="off-topic" - [[gateway.out]] account="irc.freenode" channel="#testing" - [[gateway.out]] + [[gateway.inout]] account="mattermost.work" channel="off-topic"