summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-07-09 13:41:46 +0200
committerWim <wim@42.be>2017-07-09 13:41:46 +0200
commit870b89a8f031903ac53780ec4f09a36532998df6 (patch)
tree5cc2bca858be37a2c78c002fd87b565e0a75e791
parent65ac96913c914ade814cfe55fe9952126abb440e (diff)
downloadmatterbridge-msglm-870b89a8f031903ac53780ec4f09a36532998df6.tar.gz
matterbridge-msglm-870b89a8f031903ac53780ec4f09a36532998df6.tar.bz2
matterbridge-msglm-870b89a8f031903ac53780ec4f09a36532998df6.zip
Fix embeds (discord). Closes #202
-rw-r--r--bridge/discord/discord.go26
1 files changed, 17 insertions, 9 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index e3ea9f9b..14fc8615 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -153,33 +153,41 @@ func (b *bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
if b.Config.WebhookURL != "" && m.Author.Bot && m.Author.ID == b.webhookID {
return
}
+
if len(m.Attachments) > 0 {
for _, attach := range m.Attachments {
m.Content = m.Content + "\n" + attach.URL
}
}
- if m.Content == "" {
- return
+
+ var text string
+ if m.Content != "" {
+ flog.Debugf("Receiving message %#v", m.Message)
+ if len(m.MentionRoles) > 0 {
+ m.Message.Content = b.replaceRoleMentions(m.Message.Content)
+ }
+ m.Message.Content = b.stripCustomoji(m.Message.Content)
+ m.Message.Content = b.replaceChannelMentions(m.Message.Content)
+ text = m.ContentWithMentionsReplaced()
}
- flog.Debugf("Receiving message %#v", m.Message)
+
channelName := b.getChannelName(m.ChannelID)
if b.UseChannelID {
channelName = "ID:" + m.ChannelID
}
username := b.getNick(m.Author)
- if len(m.MentionRoles) > 0 {
- m.Message.Content = b.replaceRoleMentions(m.Message.Content)
- }
- m.Message.Content = b.stripCustomoji(m.Message.Content)
- m.Message.Content = b.replaceChannelMentions(m.Message.Content)
- text := m.ContentWithMentionsReplaced()
if b.Config.ShowEmbeds && m.Message.Embeds != nil {
for _, embed := range m.Message.Embeds {
text = text + "embed: " + embed.Title + " - " + embed.Description + " - " + embed.URL + "\n"
}
}
+ // no empty messages
+ if text == "" {
+ return
+ }
+
flog.Debugf("Sending message from %s on %s to gateway", m.Author.Username, b.Account)
b.Remote <- config.Message{Username: username, Text: text, Channel: channelName,
Account: b.Account, Avatar: "https://cdn.discordapp.com/avatars/" + m.Author.ID + "/" + m.Author.Avatar + ".jpg",