remote_avatar: add UseLocalAvatar
This commit is contained in:
@@ -138,6 +138,7 @@ type Protocol struct {
|
|||||||
Topic string // zulip
|
Topic string // zulip
|
||||||
URL string // mattermost, slack // DEPRECATED
|
URL string // mattermost, slack // DEPRECATED
|
||||||
UseAPI bool // mattermost, slack
|
UseAPI bool // mattermost, slack
|
||||||
|
UseLocalAvatar []string // discord
|
||||||
UseSASL bool // IRC
|
UseSASL bool // IRC
|
||||||
UseTLS bool // IRC
|
UseTLS bool // IRC
|
||||||
UseDiscriminator bool // discord
|
UseDiscriminator bool // discord
|
||||||
|
|||||||
@@ -381,6 +381,19 @@ 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 msg.Avatar == "" {
|
||||||
|
for _, val := range b.GetStringSlice("UseLocalAvatar") {
|
||||||
|
if msg.Protocol != val {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if avatar, ok := b.findAvatar(msg); ok {
|
||||||
|
msg.Avatar = avatar
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WebhookParams can have either `Content` or `File`.
|
// WebhookParams can have either `Content` or `File`.
|
||||||
|
|
||||||
// We can't send empty messages.
|
// We can't send empty messages.
|
||||||
@@ -430,3 +443,11 @@ 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) {
|
||||||
|
member, err := b.getGuildMemberByNick(m.Username)
|
||||||
|
if err != nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
return member.User.AvatarURL(""), true
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user