diff options
author | Wim <wim@42.be> | 2017-06-24 19:36:10 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-06-29 23:38:48 +0200 |
commit | 830361e48bab699d7a22af1eba3f3df85ac21bd3 (patch) | |
tree | a5b3c02f33efb5ed5c629f923e104ad287bc5842 /bridge/config/config.go | |
parent | 1b1a9ce2503021c275a470c8da21d33bbdcf5681 (diff) | |
download | matterbridge-msglm-830361e48bab699d7a22af1eba3f3df85ac21bd3.tar.gz matterbridge-msglm-830361e48bab699d7a22af1eba3f3df85ac21bd3.tar.bz2 matterbridge-msglm-830361e48bab699d7a22af1eba3f3df85ac21bd3.zip |
Deprecate URL,useAPI,BindAddress (slack,mattermost,rocketchat)v0.16.0-rc1
Diffstat (limited to 'bridge/config/config.go')
-rw-r--r-- | bridge/config/config.go | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/bridge/config/config.go b/bridge/config/config.go index 6244dd6a..fc41fe02 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -40,7 +40,7 @@ type ChannelInfo struct { type Protocol struct { AuthCode string // steam - BindAddress string // mattermost, slack + BindAddress string // mattermost, slack // DEPRECATED Buffer int // api EditSuffix string // mattermost, slack, discord, telegram, gitter EditDisable bool // mattermost, slack, discord, telegram, gitter @@ -72,12 +72,14 @@ type Protocol struct { SkipTLSVerify bool // IRC, mattermost Team string // mattermost Token string // gitter, slack, discord, api - URL string // mattermost, slack, matrix + URL string // mattermost, slack // DEPRECATED UseAPI bool // mattermost, slack UseSASL bool // IRC UseTLS bool // IRC UseFirstName bool // telegram - WebhookURL string // discord + WebhookBindAddress string // mattermost, slack + WebhookURL string // mattermost, slack + WebhookUse string // mattermost, slack, discord } type ChannelOptions struct { @@ -128,6 +130,28 @@ func NewConfig(cfgfile string) *Config { if _, err := toml.DecodeFile(cfgfile, &cfg); err != nil { log.Fatal(err) } + fail := false + for k, v := range cfg.Mattermost { + res := Deprecated(v, "mattermost."+k) + if res { + fail = res + } + } + for k, v := range cfg.Slack { + res := Deprecated(v, "slack."+k) + if res { + fail = res + } + } + for k, v := range cfg.Rocketchat { + res := Deprecated(v, "rocketchat."+k) + if res { + fail = res + } + } + if fail { + log.Fatalf("Fix your config. Please see changelog for more information") + } return &cfg } @@ -178,3 +202,17 @@ func GetIconURL(msg *Message, cfg *Protocol) string { iconURL = strings.Replace(iconURL, "{PROTOCOL}", protocol, -1) return iconURL } + +func Deprecated(cfg Protocol, account string) bool { + if cfg.BindAddress != "" { + log.Printf("ERROR: %s BindAddress is deprecated, you need to change it to WebhookBindAddress.", account) + } else if cfg.URL != "" { + log.Printf("ERROR: %s URL is deprecated, you need to change it to WebhookURL.", account) + } else if cfg.UseAPI == true { + log.Printf("ERROR: %s UseAPI is deprecated, it's enabled by default, please remove it from your config file.", account) + } else { + return false + } + return true + //log.Fatalf("ERROR: Fix your config: %s", account) +} |