2021-11-03 13:48:30 +00:00
|
|
|
package twitch
|
|
|
|
|
2021-11-19 18:37:42 +00:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/strimertul/strimertul/database"
|
|
|
|
)
|
2021-11-03 13:48:30 +00:00
|
|
|
|
|
|
|
const BotModulesConfigKey = "twitch/bot-modules/config"
|
|
|
|
|
|
|
|
type BotModulesConfig struct {
|
|
|
|
EnableTimers bool `json:"enable_timers"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *Bot) LoadModules() error {
|
|
|
|
var cfg BotModulesConfig
|
|
|
|
err := b.api.db.GetJSON(BotModulesConfigKey, &cfg)
|
|
|
|
if err != nil {
|
2021-11-19 18:37:42 +00:00
|
|
|
if !errors.Is(err, database.ErrKeyNotFound) {
|
2021-11-03 13:48:30 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
cfg = BotModulesConfig{
|
|
|
|
EnableTimers: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if cfg.EnableTimers {
|
2021-11-05 21:54:42 +00:00
|
|
|
b.logger.Debug("starting timer module")
|
2021-11-03 13:48:30 +00:00
|
|
|
b.Timers = SetupTimers(b)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|