explicit telegram enable flag
This commit is contained in:
@@ -57,9 +57,10 @@ func (tw TierWeights) AsSlice() [7]int {
|
||||
}
|
||||
|
||||
type TelegramConfig struct {
|
||||
Token string `toml:"token"`
|
||||
ChatID int64 `toml:"chat_id"`
|
||||
SendAt string `toml:"send_at"`
|
||||
Enabled bool `toml:"enabled"`
|
||||
Token string `toml:"token"`
|
||||
ChatID int64 `toml:"chat_id"`
|
||||
SendAt string `toml:"send_at"`
|
||||
}
|
||||
|
||||
type WebConfig struct {
|
||||
@@ -137,9 +138,12 @@ func validate(cfg *Config) error {
|
||||
if sum := cfg.Search.TierWeights.Sum(); sum != 100 {
|
||||
return fmt.Errorf("search.tier_weights must sum to 100, got %d", sum)
|
||||
}
|
||||
if cfg.Telegram.Token != "" {
|
||||
if cfg.Telegram.Enabled {
|
||||
if cfg.Telegram.Token == "" {
|
||||
return fmt.Errorf("telegram.token is required when telegram.enabled = true")
|
||||
}
|
||||
if cfg.Telegram.ChatID == 0 {
|
||||
return fmt.Errorf("telegram.chat_id is required when telegram.token is set")
|
||||
return fmt.Errorf("telegram.chat_id is required when telegram.enabled = true")
|
||||
}
|
||||
if !timeFormatRe.MatchString(cfg.Telegram.SendAt) {
|
||||
return fmt.Errorf("telegram.send_at must be in HH:MM format, got %q", cfg.Telegram.SendAt)
|
||||
|
||||
Reference in New Issue
Block a user