69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
package config
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
TelegramBotToken string
|
|
TelegramProxy string
|
|
|
|
EmailSMTPHost string
|
|
EmailSMTPPort string
|
|
EmailIMAPHost string
|
|
EmailIMAPPort string
|
|
EmailUsername string
|
|
EmailPassword string
|
|
EmailFromAddr string
|
|
|
|
DeepSeekAPIKey string
|
|
|
|
BraveAPIKey string
|
|
|
|
PostgresConnString string
|
|
}
|
|
|
|
func Load() (*Config, error) {
|
|
cfg := &Config{
|
|
TelegramBotToken: os.Getenv("TELEGRAM_BOT_TOKEN"),
|
|
TelegramProxy: os.Getenv("TELEGRAM_PROXY"),
|
|
|
|
EmailSMTPHost: os.Getenv("EMAIL_SMTP_HOST"),
|
|
EmailSMTPPort: os.Getenv("EMAIL_SMTP_PORT"),
|
|
EmailIMAPHost: os.Getenv("EMAIL_IMAP_HOST"),
|
|
EmailIMAPPort: os.Getenv("EMAIL_IMAP_PORT"),
|
|
EmailUsername: os.Getenv("EMAIL_USERNAME"),
|
|
EmailPassword: os.Getenv("EMAIL_PASSWORD"),
|
|
EmailFromAddr: os.Getenv("EMAIL_FROM_ADDR"),
|
|
|
|
DeepSeekAPIKey: os.Getenv("DEEPSEEK_API_KEY"),
|
|
|
|
BraveAPIKey: os.Getenv("BRAVE_API_KEY"),
|
|
|
|
PostgresConnString: os.Getenv("POSTGRES_CONN_STRING"),
|
|
}
|
|
|
|
if cfg.EmailSMTPPort == "" {
|
|
cfg.EmailSMTPPort = "465"
|
|
}
|
|
if cfg.EmailIMAPPort == "" {
|
|
cfg.EmailIMAPPort = "993"
|
|
}
|
|
|
|
if cfg.DeepSeekAPIKey == "" {
|
|
return nil, errors.New("DEEPSEEK_API_KEY is required")
|
|
}
|
|
if cfg.TelegramBotToken == "" {
|
|
return nil, errors.New("TELEGRAM_BOT_TOKEN is required")
|
|
}
|
|
if cfg.BraveAPIKey == "" {
|
|
return nil, errors.New("BRAVE_API_KEY is required")
|
|
}
|
|
if cfg.PostgresConnString == "" {
|
|
return nil, errors.New("POSTGRES_CONN_STRING is required")
|
|
}
|
|
|
|
return cfg, nil
|
|
}
|