remote_avatar: clarify something

This commit is contained in:
Qais Patankar
2020-02-09 12:54:43 +00:00
parent 973a2f82e3
commit ba1de67dfc

View File

@@ -381,18 +381,18 @@ func (b *Bdiscord) webhookSend(msg *config.Message, webhookID, token string) (*d
err error err error
) )
// If avatar is unset, maybe we need to set the local avatar // If avatar is unset, check if UseLocalAvatar contains the message's
// account or protocol, and if so, try to find a local avatar
if msg.Avatar == "" { if msg.Avatar == "" {
for _, val := range b.GetStringSlice("UseLocalAvatar") { for _, val := range b.GetStringSlice("UseLocalAvatar") {
if msg.Protocol != val && msg.Account != val { if msg.Protocol == val || msg.Account == val {
continue if avatar := b.findAvatar(msg); avatar != "" {
}
if avatar, ok := b.findAvatar(msg); ok {
msg.Avatar = avatar msg.Avatar = avatar
} }
break break
} }
} }
}
// WebhookParams can have either `Content` or `File`. // WebhookParams can have either `Content` or `File`.
@@ -444,10 +444,10 @@ func (b *Bdiscord) webhookSend(msg *config.Message, webhookID, token string) (*d
return res, err return res, err
} }
func (b *Bdiscord) findAvatar(m *config.Message) (string, bool) { func (b *Bdiscord) findAvatar(m *config.Message) string {
member, err := b.getGuildMemberByNick(m.Username) member, err := b.getGuildMemberByNick(m.Username)
if err != nil { if err != nil {
return "", false return ""
} }
return member.User.AvatarURL(""), true return member.User.AvatarURL("")
} }