rename account data keys, rearrange code
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// account data key
|
||||
const botsettingskey = "cc.etke.postmoogle.config"
|
||||
const acBotSettingsKey = "cc.etke.postmoogle.config"
|
||||
|
||||
// bot options keys
|
||||
const (
|
||||
@@ -48,26 +48,26 @@ func (b *Bot) migrateBotSettings(users []string) error {
|
||||
}
|
||||
|
||||
func (b *Bot) getBotSettings() botsettings {
|
||||
cfg := b.botcfg.Get(botsettingskey)
|
||||
cfg := b.botcfg.Get(acBotSettingsKey)
|
||||
if cfg != nil {
|
||||
return cfg
|
||||
}
|
||||
|
||||
config := botsettings{}
|
||||
err := b.lp.GetClient().GetAccountData(botsettingskey, &config)
|
||||
err := b.lp.GetClient().GetAccountData(acBotSettingsKey, &config)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "M_NOT_FOUND") {
|
||||
err = nil
|
||||
}
|
||||
b.log.Error("cannot get bot settings: %v", utils.UnwrapError(err))
|
||||
} else {
|
||||
b.botcfg.Set(botsettingskey, config)
|
||||
b.botcfg.Set(acBotSettingsKey, config)
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
func (b *Bot) setBotSettings(cfg botsettings) error {
|
||||
b.botcfg.Set(botsettingskey, cfg)
|
||||
return utils.UnwrapError(b.lp.GetClient().SetAccountData(botsettingskey, cfg))
|
||||
b.botcfg.Set(acBotSettingsKey, cfg)
|
||||
return utils.UnwrapError(b.lp.GetClient().SetAccountData(acBotSettingsKey, cfg))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user