@@ -152,7 +152,8 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
|
|||||||
msg.Text = "_" + msg.Text + "_"
|
msg.Text = "_" + msg.Text + "_"
|
||||||
}
|
}
|
||||||
|
|
||||||
// use initial webhook
|
// use initial webhook configured for the entire Discord account
|
||||||
|
isGlobalWebhook := true
|
||||||
wID := b.webhookID
|
wID := b.webhookID
|
||||||
wToken := b.webhookToken
|
wToken := b.webhookToken
|
||||||
|
|
||||||
@@ -161,6 +162,7 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
|
|||||||
if ci, ok := b.channelInfoMap[msg.Channel+b.Account]; ok {
|
if ci, ok := b.channelInfoMap[msg.Channel+b.Account]; ok {
|
||||||
if ci.Options.WebhookURL != "" {
|
if ci.Options.WebhookURL != "" {
|
||||||
wID, wToken = b.splitURL(ci.Options.WebhookURL)
|
wID, wToken = b.splitURL(ci.Options.WebhookURL)
|
||||||
|
isGlobalWebhook = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b.channelsMutex.RUnlock()
|
b.channelsMutex.RUnlock()
|
||||||
@@ -189,6 +191,18 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
|
|||||||
if len(msg.Username) > 32 {
|
if len(msg.Username) > 32 {
|
||||||
msg.Username = msg.Username[0:32]
|
msg.Username = msg.Username[0:32]
|
||||||
}
|
}
|
||||||
|
// if we have a global webhook for this Discord account, use it, but
|
||||||
|
// first set its channel to the message channel
|
||||||
|
// TODO: this isn't necessary if the last message from this webhook was
|
||||||
|
// sent to the current channel
|
||||||
|
if isGlobalWebhook {
|
||||||
|
b.Log.Debugf("Setting webhook channel to \"%s\"", msg.Channel)
|
||||||
|
_, err := b.c.WebhookEdit(wID, "", "", channelID)
|
||||||
|
if err != nil {
|
||||||
|
b.Log.Errorf("Could not set webhook channel: %v", err)
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
err := b.c.WebhookExecute(
|
err := b.c.WebhookExecute(
|
||||||
wID,
|
wID,
|
||||||
wToken,
|
wToken,
|
||||||
|
|||||||
Reference in New Issue
Block a user