mirror of
https://github.com/42wim/matterbridge
synced 2024-11-19 03:25:33 +00:00
Fix embeds (discord). Closes #202
This commit is contained in:
parent
65ac96913c
commit
870b89a8f0
@ -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 {
|
if b.Config.WebhookURL != "" && m.Author.Bot && m.Author.ID == b.webhookID {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(m.Attachments) > 0 {
|
if len(m.Attachments) > 0 {
|
||||||
for _, attach := range m.Attachments {
|
for _, attach := range m.Attachments {
|
||||||
m.Content = m.Content + "\n" + attach.URL
|
m.Content = m.Content + "\n" + attach.URL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if m.Content == "" {
|
|
||||||
return
|
var text string
|
||||||
}
|
if m.Content != "" {
|
||||||
flog.Debugf("Receiving message %#v", m.Message)
|
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 {
|
if len(m.MentionRoles) > 0 {
|
||||||
m.Message.Content = b.replaceRoleMentions(m.Message.Content)
|
m.Message.Content = b.replaceRoleMentions(m.Message.Content)
|
||||||
}
|
}
|
||||||
m.Message.Content = b.stripCustomoji(m.Message.Content)
|
m.Message.Content = b.stripCustomoji(m.Message.Content)
|
||||||
m.Message.Content = b.replaceChannelMentions(m.Message.Content)
|
m.Message.Content = b.replaceChannelMentions(m.Message.Content)
|
||||||
|
text = m.ContentWithMentionsReplaced()
|
||||||
|
}
|
||||||
|
|
||||||
|
channelName := b.getChannelName(m.ChannelID)
|
||||||
|
if b.UseChannelID {
|
||||||
|
channelName = "ID:" + m.ChannelID
|
||||||
|
}
|
||||||
|
username := b.getNick(m.Author)
|
||||||
|
|
||||||
text := m.ContentWithMentionsReplaced()
|
|
||||||
if b.Config.ShowEmbeds && m.Message.Embeds != nil {
|
if b.Config.ShowEmbeds && m.Message.Embeds != nil {
|
||||||
for _, embed := range m.Message.Embeds {
|
for _, embed := range m.Message.Embeds {
|
||||||
text = text + "embed: " + embed.Title + " - " + embed.Description + " - " + embed.URL + "\n"
|
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)
|
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,
|
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",
|
Account: b.Account, Avatar: "https://cdn.discordapp.com/avatars/" + m.Author.ID + "/" + m.Author.Avatar + ".jpg",
|
||||||
|
Loading…
Reference in New Issue
Block a user