mirror of
https://github.com/42wim/matterbridge.git
synced 2025-01-18 13:09:03 -08:00
discord: put attachment URLs into Extra["file"]
previously, the urls were just appended to the message content. i couldn't find any other assignments directly to Extra["file"] anywhere in the codebase, so maybe there's a better way to do this.
This commit is contained in:
parent
d16645c952
commit
ac2f7da59d
@ -98,15 +98,19 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
rmsg := config.Message{Account: b.Account, Avatar: "https://cdn.discordapp.com/avatars/" + m.Author.ID + "/" + m.Author.Avatar + ".jpg", UserID: m.Author.ID, ID: m.ID, Extra: make(map[string][]interface{}, 0)}
|
||||
|
||||
// add the url of the attachments to content
|
||||
if len(m.Attachments) > 0 {
|
||||
for _, attach := range m.Attachments {
|
||||
m.Content = m.Content + "\n" + attach.URL
|
||||
rmsg.Extra["file"] = append(rmsg.Extra["file"], config.FileInfo {
|
||||
URL: attach.URL,
|
||||
})
|
||||
// m.Content = m.Content + "\n" + attach.URL
|
||||
}
|
||||
}
|
||||
|
||||
rmsg := config.Message{Account: b.Account, Avatar: "https://cdn.discordapp.com/avatars/" + m.Author.ID + "/" + m.Author.Avatar + ".jpg", UserID: m.Author.ID, ID: m.ID}
|
||||
|
||||
b.Log.Debugf("== Receiving event %#v", m.Message)
|
||||
|
||||
if m.Content != "" {
|
||||
@ -139,7 +143,7 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
|
||||
}
|
||||
|
||||
// no empty messages
|
||||
if rmsg.Text == "" {
|
||||
if rmsg.Text == "" && len(rmsg.Extra["file"]) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user