5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-22 12:50:27 +00:00

Add gateway.inout config for bidirectional bridges. Closes #85

This commit is contained in:
Wim 2016-11-20 23:01:44 +01:00
parent d5845ce900
commit e0e1e4be80
4 changed files with 12 additions and 11 deletions

View File

@ -62,6 +62,7 @@ type Gateway struct {
Enable bool Enable bool
In []Bridge In []Bridge
Out []Bridge Out []Bridge
InOut []Bridge
} }
type SameChannelGateway struct { type SameChannelGateway struct {

View File

@ -57,7 +57,7 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error {
func (gw *Gateway) Start() error { func (gw *Gateway) Start() error {
gw.mapChannels() 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) err := gw.AddBridge(&br)
if err != nil { if err != nil {
return err return err
@ -92,6 +92,10 @@ func (gw *Gateway) mapChannels() error {
m[br.Account] = append(m[br.Account], br.Channel) m[br.Account] = append(m[br.Account], br.Channel)
} }
gw.ChannelsIn = m 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 return nil
} }

View File

@ -383,7 +383,7 @@ ShowJoinPart=false
#from [[gateway.in]] to. #from [[gateway.in]] to.
# #
#Most of the time [[gateway.in]] and [[gateway.out]] are the same if you #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]] [[gateway]]
@ -415,15 +415,15 @@ enable=true
#REQUIRED #REQUIRED
channel="#testing" channel="#testing"
[[gateway.in]]
account="mattermost.work"
channel="off-topic"
#[[gateway.out]] specifies the account and channels we will sent messages to.
[[gateway.out]] [[gateway.out]]
account="irc.freenode" account="irc.freenode"
channel="#testing" 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" account="mattermost.work"
channel="off-topic" channel="off-topic"

View File

@ -19,14 +19,10 @@ enable=true
account="irc.freenode" account="irc.freenode"
channel="#testing" channel="#testing"
[[gateway.in]]
account="mattermost.work"
channel="off-topic"
[[gateway.out]] [[gateway.out]]
account="irc.freenode" account="irc.freenode"
channel="#testing" channel="#testing"
[[gateway.out]] [[gateway.inout]]
account="mattermost.work" account="mattermost.work"
channel="off-topic" channel="off-topic"