mirror of
https://git.sr.ht/~ashkeel/strimertul
synced 2024-09-20 02:00:49 +00:00
0d3233ecbd
Changing the HTTP config will now restart the server or, if possible, just hotpatch the configuration
32 lines
581 B
Go
32 lines
581 B
Go
package twitch
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/strimertul/strimertul/database"
|
|
)
|
|
|
|
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 {
|
|
if !errors.Is(err, database.ErrKeyNotFound) {
|
|
return err
|
|
}
|
|
cfg = BotModulesConfig{
|
|
EnableTimers: false,
|
|
}
|
|
}
|
|
if cfg.EnableTimers {
|
|
b.logger.Debug("starting timer module")
|
|
b.Timers = SetupTimers(b)
|
|
}
|
|
return nil
|
|
}
|