properly update mailbox, fixes #9

This commit is contained in:
Aine
2022-08-28 09:37:18 +03:00
parent 6eae1a65c4
commit 13776ad7a6
3 changed files with 25 additions and 15 deletions

View File

@@ -256,11 +256,16 @@ func (b *Bot) setOption(ctx context.Context, name, value string) {
return
}
old := cfg.Get(name)
cfg.Set(name, value)
if name == optionMailbox {
value = fmt.Sprintf("%s@%s", value, b.domain)
cfg.Set(optionOwner, evt.Sender.String())
if old != "" {
b.rooms.Delete(old)
}
b.rooms.Store(value, evt.RoomID)
value = fmt.Sprintf("%s@%s", value, b.domain)
}
err = b.setSettings(evt.RoomID, cfg)