diff options
author | Wim <wim@42.be> | 2017-08-12 16:30:00 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-08-12 16:30:00 +0200 |
commit | e77c3eb20a26f0e673038749e4ca76e7a47e775c (patch) | |
tree | 3b13ae7888aa6213b99d29622a495249dc4543e0 | |
parent | 59b2a5f8d0cb782cc94f06c034723b3d7da43dcc (diff) | |
download | matterbridge-msglm-e77c3eb20a26f0e673038749e4ca76e7a47e775c.tar.gz matterbridge-msglm-e77c3eb20a26f0e673038749e4ca76e7a47e775c.tar.bz2 matterbridge-msglm-e77c3eb20a26f0e673038749e4ca76e7a47e775c.zip |
Swap token/id. Also check for default webhookURL in isWebhookID (discord)
-rw-r--r-- | bridge/discord/discord.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go index 2868eeb5..7debcda0 100644 --- a/bridge/discord/discord.go +++ b/bridge/discord/discord.go @@ -41,7 +41,7 @@ func New(cfg config.Protocol, account string, c chan config.Message) *bdiscord { b.channelInfoMap = make(map[string]*config.ChannelInfo) if b.Config.WebhookURL != "" { flog.Debug("Configuring Discord Incoming Webhook") - b.webhookToken, b.webhookID = b.splitURL(b.Config.WebhookURL) + b.webhookID, b.webhookToken = b.splitURL(b.Config.WebhookURL) } return b } @@ -121,7 +121,7 @@ func (b *bdiscord) Send(msg config.Message) error { wID := b.webhookID wToken := b.webhookToken - if ci, ok := b.channelInfoMap[msg.Channel+msg.Account]; ok { + if ci, ok := b.channelInfoMap[msg.Channel+b.Account]; ok { if ci.Options.WebhookURL != "" { wID, wToken = b.splitURL(ci.Options.WebhookURL) } @@ -131,7 +131,7 @@ func (b *bdiscord) Send(msg config.Message) error { flog.Debugf("Broadcasting using token (API)") b.c.ChannelMessageSend(channelID, msg.Username+msg.Text) } else { - flog.Debugf("Broadcasting using Webhook %#v %#v", wID, wToken) + flog.Debugf("Broadcasting using Webhook") b.c.WebhookExecute( wID, wToken, @@ -342,6 +342,12 @@ func (b *bdiscord) useWebhook() bool { // isWebhookID returns true if the specified id is used in a defined webhook func (b *bdiscord) isWebhookID(id string) bool { + if b.Config.WebhookURL != "" { + wID, _ := b.splitURL(b.Config.WebhookURL) + if wID == id { + return true + } + } for _, channel := range b.channelInfoMap { if channel.Options.WebhookURL != "" { wID, _ := b.splitURL(channel.Options.WebhookURL) |