mirror-nourybot/pkg/config/config.go

35 lines
530 B
Go
Raw Normal View History

2021-10-13 21:30:31 +02:00
package config
import (
"os"
"github.com/joho/godotenv"
log "github.com/sirupsen/logrus"
)
type Config struct {
2021-10-14 00:45:32 +02:00
Username string
Oauth string
BotUserId string
2021-10-25 23:33:00 +02:00
MongoURI string
2021-10-13 21:30:31 +02:00
}
func LoadConfig() *Config {
err := godotenv.Load()
2021-10-21 00:07:18 +02:00
2021-10-13 21:30:31 +02:00
if err != nil {
log.Fatal("Error loading .env")
}
cfg := &Config{
2021-10-14 00:45:32 +02:00
Username: os.Getenv("TWITCH_USER"),
Oauth: os.Getenv("TWITCH_PASS"),
BotUserId: os.Getenv("BOT_USER_ID"),
2021-10-25 23:33:00 +02:00
MongoURI: os.Getenv("MONGO_URI"),
2021-10-13 21:30:31 +02:00
}
2021-10-21 00:07:18 +02:00
2021-10-13 21:30:31 +02:00
log.Info("Config loaded succesfully")
return cfg
}