package config import ( "os" "strings" ) // Config holds all application configuration type Config struct { Debug bool Hostname string Port string LogLevel string SecretKey string DatabasePath string SlackConfig SlackConfig TelegramConfig TelegramConfig } // SlackConfig holds Slack platform configuration type SlackConfig struct { Token string BotOAuthAccessToken string } // TelegramConfig holds Telegram platform configuration type TelegramConfig struct { Token string } // Load loads configuration from environment variables func Load() (*Config, error) { config := &Config{ Debug: getEnv("DEBUG", "n") == "y", Hostname: getEnv("BUTTERROBOT_HOSTNAME", "butterrobot-dev.int.fmartingr.network"), Port: getEnv("PORT", "8080"), LogLevel: getEnv("LOG_LEVEL", "ERROR"), SecretKey: getEnv("SECRET_KEY", "1234"), DatabasePath: getEnv("DATABASE_PATH", "butterrobot.db"), SlackConfig: SlackConfig{ Token: getEnv("SLACK_TOKEN", ""), BotOAuthAccessToken: getEnv("SLACK_BOT_OAUTH_ACCESS_TOKEN", ""), }, TelegramConfig: TelegramConfig{ Token: getEnv("TELEGRAM_TOKEN", ""), }, } return config, nil } // getEnv retrieves an environment variable value or returns a default value func getEnv(key, defaultValue string) string { value := os.Getenv(key) if strings.TrimSpace(value) == "" { return defaultValue } return value }