mirror of
https://github.com/mautrix/discord.git
synced 2025-03-14 14:15:37 +00:00
42 lines
788 B
Go
42 lines
788 B
Go
package bridge
|
|
|
|
import (
|
|
"maunium.net/go/mautrix/id"
|
|
)
|
|
|
|
func (b *Bridge) updateBotProfile() {
|
|
cfg := b.Config.Appservice.Bot
|
|
|
|
// Set the bot's avatar.
|
|
if cfg.Avatar != "" {
|
|
var err error
|
|
var mxc id.ContentURI
|
|
|
|
if cfg.Avatar == "remove" {
|
|
err = b.bot.SetAvatarURL(mxc)
|
|
} else {
|
|
mxc, err = id.ParseContentURI(cfg.Avatar)
|
|
if err == nil {
|
|
err = b.bot.SetAvatarURL(mxc)
|
|
}
|
|
}
|
|
if err != nil {
|
|
b.log.Warnln("failed to update the bot's avatar: ", err)
|
|
}
|
|
}
|
|
|
|
// Update the bot's display name.
|
|
if cfg.Displayname != "" {
|
|
var err error
|
|
|
|
if cfg.Displayname == "remove" {
|
|
err = b.bot.SetDisplayName("")
|
|
} else {
|
|
err = b.bot.SetDisplayName(cfg.Displayname)
|
|
}
|
|
|
|
if err != nil {
|
|
b.log.Warnln("failed to update the bot's display name", err)
|
|
}
|
|
}
|
|
}
|