mirror of
https://github.com/watn3y/steamsalty.git
synced 2025-06-07 15:21:00 +02:00
v0.1
This commit is contained in:
parent
6aa64b6287
commit
3ec330e3a2
16 changed files with 408 additions and 1 deletions
24
config/config.go
Normal file
24
config/config.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
envconfig "github.com/sethvargo/go-envconfig"
|
||||
)
|
||||
|
||||
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.Info().Msg("Loaded config")
|
||||
log.Debug().Interface("config", BotConfig).Msg("")
|
||||
|
||||
}
|
9
config/types.go
Normal file
9
config/types.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
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"`
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue