Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 5d442102285026b0ce77a24aac34201192f65fe1 Author: Wim <wim@42.be> Date: Sun Nov 20 23:01:44 2016 +0000 Add gateway.inout config for bidirectional bridges. Closes #85 diff --git a/bridge/config/config.go b/bridge/config/config.go index 5fed2f0..1958bf5 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -626 +627 @@ 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 63da4bb..f45f315 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -577 +577 @@ 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 @@ -926 +9210 @@ 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 2e5f818..df73713 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -3837 +3837 @@ 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]] @@ -41515 +41515 @@ 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 30104d9..d39a33f 100644 --- a/matterbridge.toml.simple +++ b/matterbridge.toml.simple @@ -1914 +1910 @@ 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"