commit 09ddbed713ee80b5df414223d1a3a37bf83b900b
Author: Wim <wim@42.be>
Date: Wed Jan 04 14:10:35 2017 +0000
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 971013d..ac3e939 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -529 +5214 @@ type Protocol struct {
UseTLS bool // IRC
}
+type ChannelOptions struct {
+ Key string // irc
+}
+
type Bridge struct {
Account string
Channel string
+ Options ChannelOptions
}
type Gateway struct {
diff --git a/gateway/gateway.go b/gateway/gateway.go
index e36d1a4..4177973 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -1312 +1313 @@ type Gateway struct {
*config.Config
MyConfig *config.Gateway
//Bridges []*bridge.Bridge
- Bridges map[string]*bridge.Bridge
- ChannelsOut map[string][]string
- ChannelsIn map[string][]string
- ignoreNicks map[string][]string
- Name string
- Message chan config.Message
+ Bridges map[string]*bridge.Bridge
+ ChannelsOut map[string][]string
+ ChannelsIn map[string][]string
+ ignoreNicks map[string][]string
+ ChannelOptions map[string]config.ChannelOptions
+ Name string
+ Message chan config.Message
}
func New(cfg *config.Config, gateway *config.Gateway) *Gateway {
@@ -478 +4813 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error {
exists := make(map[string]bool)
for _, channel := range append(gw.ChannelsOut[br.Account], gw.ChannelsIn[br.Account]...) {
if !exists[br.Account+channel] {
+ mychannel := channel
log.Infof("%s: joining %s", br.Account, channel)
- br.JoinChannel(channel)
+ if br.Protocol == "irc" && gw.ChannelOptions[br.Account+channel].Key != "" {
+ log.Debugf("using key %s for channel %s", gw.ChannelOptions[br.Account+channel].Key, channel)
+ mychannel = mychannel + " " + gw.ChannelOptions[br.Account+channel].Key
+ }
+ br.JoinChannel(mychannel)
exists[br.Account+channel] = true
}
}
@@ -8121 +8726 @@ func (gw *Gateway) handleReceive() {
}
func (gw *Gateway) mapChannels() error {
+ options := make(map[string]config.ChannelOptions)
m := make(map[string][]string)
for _, br := range gw.MyConfig.Out {
m[br.Account] = append(m[br.Account], br.Channel)
+ options[br.Account+br.Channel] = br.Options
}
gw.ChannelsOut = m
m = nil
m = make(map[string][]string)
for _, br := range gw.MyConfig.In {
m[br.Account] = append(m[br.Account], br.Channel)
+ options[br.Account+br.Channel] = br.Options
}
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)
+ options[br.Account+br.Channel] = br.Options
}
+ gw.ChannelOptions = options
return nil
}
diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample
index ea7f7ae..2c9a4d3 100644
--- a/matterbridge.toml.sample
+++ b/matterbridge.toml.sample
@@ -53418 +53432 @@ enable=true
+ #OPTIONAL - only used for IRC protocol at the moment
+ [gateway.in.options]
+ #OPTIONAL - your irc channel key
+ key="yourkey"
+
+ #OPTIONAL - only used for IRC protocol at the moment
+ [gateway.out.options]
+ #OPTIONAL - your irc channel key
+ key="yourkey"
+
+ #OPTIONAL - only used for IRC protocol at the moment
+ [gateway.inout.options]
+ #OPTIONAL - your irc channel key
+ key="yourkey"
#If you want to do a 1:1 mapping between protocols where the channelnames are the same
#e.g. slack and mattermost you can use the samechannelgateway configuration