diff options
author | Wim <wim@42.be> | 2018-03-04 23:52:14 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-03-04 23:52:14 +0100 |
commit | f2f1d874e1b4f997c111de87121eec98eef66381 (patch) | |
tree | 34a44e866c053ef298d5482370208a0bb9dc4738 /bridge/rocketchat/rocketchat.go | |
parent | 25a72113b122f984c904b24c4af23a1cba1eff45 (diff) | |
download | matterbridge-msglm-f2f1d874e1b4f997c111de87121eec98eef66381.tar.gz matterbridge-msglm-f2f1d874e1b4f997c111de87121eec98eef66381.tar.bz2 matterbridge-msglm-f2f1d874e1b4f997c111de87121eec98eef66381.zip |
Use viper (github.com/spf13/viper) for configuration
Diffstat (limited to 'bridge/rocketchat/rocketchat.go')
-rw-r--r-- | bridge/rocketchat/rocketchat.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/bridge/rocketchat/rocketchat.go b/bridge/rocketchat/rocketchat.go index fa6bdd5b..fa2c31d7 100644 --- a/bridge/rocketchat/rocketchat.go +++ b/bridge/rocketchat/rocketchat.go @@ -15,11 +15,11 @@ type MMhook struct { type Brocketchat struct { MMhook - *config.BridgeConfig + *bridge.Config } -func New(cfg *config.BridgeConfig) bridge.Bridger { - return &Brocketchat{BridgeConfig: cfg} +func New(cfg *bridge.Config) bridge.Bridger { + return &Brocketchat{Config: cfg} } func (b *Brocketchat) Command(cmd string) string { @@ -28,10 +28,10 @@ func (b *Brocketchat) Command(cmd string) string { func (b *Brocketchat) Connect() error { b.Log.Info("Connecting webhooks") - b.mh = matterhook.New(b.Config.WebhookURL, - matterhook.Config{InsecureSkipVerify: b.Config.SkipTLSVerify, + b.mh = matterhook.New(b.GetString("WebhookURL"), + matterhook.Config{InsecureSkipVerify: b.GetBool("SkipTLSVerify"), DisableServer: true}) - b.rh = rockethook.New(b.Config.WebhookURL, rockethook.Config{BindAddress: b.Config.WebhookBindAddress}) + b.rh = rockethook.New(b.GetString("WebhookURL"), rockethook.Config{BindAddress: b.GetString("WebhookBindAddress")}) go b.handleRocketHook() return nil } @@ -53,7 +53,7 @@ func (b *Brocketchat) Send(msg config.Message) (string, error) { b.Log.Debugf("=> Receiving %#v", msg) if msg.Extra != nil { for _, rmsg := range helper.HandleExtra(&msg, b.General) { - matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL, Channel: rmsg.Channel, UserName: rmsg.Username, + matterMessage := matterhook.OMessage{IconURL: b.GetString("IconURL"), Channel: rmsg.Channel, UserName: rmsg.Username, Text: rmsg.Text} b.mh.Send(matterMessage) } @@ -67,7 +67,7 @@ func (b *Brocketchat) Send(msg config.Message) (string, error) { } } - matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL} + matterMessage := matterhook.OMessage{IconURL: b.GetString("IconURL")} matterMessage.Channel = msg.Channel matterMessage.UserName = msg.Username matterMessage.Type = "" @@ -85,7 +85,7 @@ func (b *Brocketchat) handleRocketHook() { message := b.rh.Receive() b.Log.Debugf("Receiving from rockethook %#v", message) // do not loop - if message.UserName == b.Config.Nick { + if message.UserName == b.GetString("Nick") { continue } b.Log.Debugf("<= Sending message from %s on %s to gateway", message.UserName, b.Account) |