- Fixed SLEEPTIME not working (always 0)
- Refined logging
- Added metadata to /info command
- Bot now automatically sets own commands for autocompletion
This commit is contained in:
Noah 2024-12-22 07:13:19 +01:00
parent eb0482b8e0
commit 6be403fc58
14 changed files with 116 additions and 53 deletions

View file

@ -2,6 +2,7 @@ package config
import (
"context"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
envconfig "github.com/sethvargo/go-envconfig"
@ -11,12 +12,9 @@ var BotConfig config
func LoadConfig() {
if err := envconfig.Process(context.Background(), &BotConfig); err != nil {
log.Panic().Err(err).Msg("error parsing config from env variables")
}
if !BotConfig.DebugMode {
zerolog.SetGlobalLevel(zerolog.InfoLevel)
log.Panic().Err(err).Msg("Error parsing config from env variables")
}
zerolog.SetGlobalLevel(zerolog.Level(BotConfig.LogLevel))
log.Info().Msg("Loaded config")
log.Debug().Interface("config", BotConfig).Msg("")

View file

@ -1,10 +1,10 @@
package config
type config struct {
TelegramAPIToken string `env:"TELEGRAMAPITOKEN, required"`
SteamAPIKey string `env:"STEAMAPIKEY, required"`
DebugMode bool `env:"DEBUGMODE, default=false"`
ChatID int64 `env:"CHATID"`
Watchers []uint64 `env:"WATCHERS"`
SleepInterval int `env:"SLEEPINTERVAL"`
LogLevel int `env:"STEAMSALTY_LOGLEVEL, default=1"`
TelegramAPIToken string `env:"STEAMSALTY_TELEGRAMAPITOKEN, required"`
SteamAPIKey string `env:"STEAMSALTY_STEAMAPIKEY, required"`
ChatID int64 `env:"STEAMSALTY_CHATID, required"`
Watchers []uint64 `env:"STEAMSALTY_WATCHERS, required"`
SleepInterval int `env:"STEAMSALTY_SLEEPINTERVAL, default=60"`
}