refactor: change translation config

This commit is contained in:
Noah 2025-10-13 14:38:15 +02:00
parent f3dec30b56
commit f445fef85a
No known key found for this signature in database
GPG key ID: D2A7E2C8F77E0430
2 changed files with 10 additions and 7 deletions

View file

@ -8,9 +8,12 @@ type config struct {
Watchers []uint64 `env:"STEAMSALTY_WATCHERS" required:"true"`
TranslateEnabled bool `env:"STEAMSALTY_TRANSLATE_ENABLED" default:"false"`
TranslateLanguage string `env:"STEAMSALTY_TRANSLATE_LANGUAGE" default:"EN-US"`
TelegramAPIToken string `env:"STEAMSALTY_TELEGRAMAPITOKEN" required:"true"`
SteamAPIKey string `env:"STEAMSALTY_STEAMAPIKEY" required:"true"`
DeepLAPIKey string `env:"STEAMSALTY_DEEPLAPIKEY"`
DeepLFreeTier bool `env:"STEAMSALTY_DEEPLAPIFREETIER" default:"true"`
TelegramAPIToken string `env:"STEAMSALTY_TELEGRAMAPITOKEN" required:"true"`
SteamAPIKey string `env:"STEAMSALTY_STEAMAPIKEY" required:"true"`
DeepL struct {
APIKey string `env:"APIKEY"`
FreeTier bool `env:"FREETIER" default:"true"`
} `env:"STEAMSALTY_DEEPL_"`
}

View file

@ -18,12 +18,12 @@ var TargetLanguages map[string]string
func Init() {
log.Info().Msg("Translation is enabled, creating HTTP client for DeepL API")
baseURL := baseURLPro
if config.BotConfig.DeepLFreeTier {
if config.BotConfig.DeepL.FreeTier {
baseURL = baseURLFree
}
client = &apiClient{
authKey: config.BotConfig.DeepLAPIKey,
authKey: config.BotConfig.DeepL.APIKey,
baseURL: baseURL,
httpClient: &http.Client{Timeout: 30 * time.Second},
}