Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 044c5283f6cdd216c2df0ce1d31642d01fa87d3d Author: Wim <wim@42.be> Date: Sat Aug 12 16:30:00 2017 +0000 Swap token/id. Also check for default webhookURL in isWebhookID (discord) diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go index 2868eeb..7debcda 100644 --- a/bridge/discord/discord.go +++ b/bridge/discord/discord.go @@ -417 +417 @@ 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  } @@ -1217 +1217 @@ 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)   } @@ -1317 +1317 @@ 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, @@ -3426 +34212 @@ 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)