diff options
author | msglm <msglm@techchud.xyz> | 2023-10-27 07:08:25 -0500 |
---|---|---|
committer | msglm <msglm@techchud.xyz> | 2023-10-27 07:08:25 -0500 |
commit | 032a7e0c1188d3507b8d9a9571f2446a43cf775b (patch) | |
tree | 2bd38c01bc7761a6195e426082ce7191ebc765a1 /bridge/discord | |
parent | 56e7bd01ca09ad52b0c4f48f146a20a4f1b78696 (diff) | |
download | matterbridge-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')
-rw-r--r-- | bridge/discord/discord.go | 15 | ||||
-rw-r--r-- | bridge/discord/handlers.go | 1 |
2 files changed, 13 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(), } diff --git a/bridge/discord/handlers.go b/bridge/discord/handlers.go index 34cef554..32baa7ab 100644 --- a/bridge/discord/handlers.go +++ b/bridge/discord/handlers.go @@ -58,6 +58,7 @@ func (b *Bdiscord) messageTyping(s *discordgo.Session, m *discordgo.TypingStart) return } + //nolint:exhaustruct rmsg := config.Message{Account: b.Account, Event: config.EventUserTyping} rmsg.Channel = b.getChannelName(m.ChannelID) b.Remote <- rmsg |