2020-08-18 20:48:55 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2024-05-12 13:04:32 +00:00
|
|
|
var GlobalConfig Config
|
|
|
|
|
2020-08-18 20:48:55 +00:00
|
|
|
// Config contains all the neccessary configurations
|
|
|
|
type Config struct {
|
2024-05-12 13:04:32 +00:00
|
|
|
OpenAIAPI OpenAI
|
2020-08-18 20:48:55 +00:00
|
|
|
Bot BotConfig
|
|
|
|
environment string
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetEnv returns the current developemnt environment
|
|
|
|
func (c Config) GetEnv() string {
|
|
|
|
return c.environment
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load reads all config from env to config
|
|
|
|
func Load() Config {
|
2024-05-12 13:04:32 +00:00
|
|
|
GlobalConfig = Config{
|
2020-08-18 20:48:55 +00:00
|
|
|
environment: os.Getenv("APP_ENV"),
|
|
|
|
Bot: BotConfig{
|
|
|
|
tkn: os.Getenv("API_TOKEN"),
|
|
|
|
},
|
2024-05-12 13:04:32 +00:00
|
|
|
OpenAIAPI: OpenAI{
|
|
|
|
Endpoint: os.Getenv("OPENAI_ENDPOINT"),
|
|
|
|
APIKey: os.Getenv("OPENAI_API_KEY"),
|
|
|
|
},
|
2020-08-18 20:48:55 +00:00
|
|
|
}
|
2024-05-12 13:04:32 +00:00
|
|
|
return GlobalConfig
|
2020-08-18 20:48:55 +00:00
|
|
|
}
|