summaryrefslogtreecommitdiffstats
path: root/bridge/discord/discord.go
diff options
context:
space:
mode:
authormsglm <msglm@techchud.xyz>2023-10-27 07:08:25 -0500
committermsglm <msglm@techchud.xyz>2023-10-27 07:08:25 -0500
commit032a7e0c1188d3507b8d9a9571f2446a43cf775b (patch)
tree2bd38c01bc7761a6195e426082ce7191ebc765a1 /bridge/discord/discord.go
parent56e7bd01ca09ad52b0c4f48f146a20a4f1b78696 (diff)
downloadmatterbridge-msglm-032a7e0c1188d3507b8d9a9571f2446a43cf775b.tar.gz
matterbridge-msglm-032a7e0c1188d3507b8d9a9571f2446a43cf775b.tar.bz2
matterbridge-msglm-032a7e0c1188d3507b8d9a9571f2446a43cf775b.zip
apply https://github.com/42wim/matterbridge/pull/1864v1.26.0+0.1.0
Diffstat (limited to 'bridge/discord/discord.go')
-rw-r--r--bridge/discord/discord.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index 51dbe6bc..90220f92 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -282,11 +282,12 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
return b.handleEventWebhook(&msg, channelID)
}
- return b.handleEventBotUser(&msg, channelID)
+ return b.handleEventBotUser(&msg, channelID, useWebhooks)
}
// handleEventDirect handles events via the bot user
-func (b *Bdiscord) handleEventBotUser(msg *config.Message, channelID string) (string, error) {
+//nolint:funlen
+func (b *Bdiscord) handleEventBotUser(msg *config.Message, channelID string, webhookPreferred bool) (string, error) {
b.Log.Debugf("Broadcasting using token (API)")
// Delete message
@@ -336,8 +337,16 @@ func (b *Bdiscord) handleEventBotUser(msg *config.Message, channelID string) (st
return msg.ID, err
}
+ content := msg.Username + msg.Text
+ // we would have preferred to use webhooks but we can't (e.g. we are replying
+ // to a message, as webhooks doesn't support that behavior)
+ // in that case, the username is probably not properly formatted for appending
+ // directly, so we add a line return as a stopgap mechanism
+ if webhookPreferred {
+ content = msg.Username + ":\n" + msg.Text
+ }
m := discordgo.MessageSend{
- Content: msg.Username + msg.Text,
+ Content: content,
AllowedMentions: b.getAllowedMentions(),
}