Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding telegram support #2827

Merged
merged 20 commits into from
Feb 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added telegram config to config.go
Signed-off-by: timmilesdw <[email protected]>
timmilesdw committed Feb 4, 2022
commit d09a4149889563f5dc832485385de06a0e1d0b20
13 changes: 13 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -245,6 +245,9 @@ func resolveFilepaths(baseDir string, cfg *Config) {
for _, cfg := range receiver.SNSConfigs {
cfg.HTTPConfig.SetDirectory(baseDir)
}
for _, cfg := range receiver.TelegramConfigs {
cfg.HTTPConfig.SetDirectory(baseDir)
}
}
}

@@ -460,6 +463,13 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
sns.HTTPConfig = c.Global.HTTPConfig
}
}

for _, telegram := range rcv.TelegramConfigs {
if telegram.APIUrl == nil {
telegram.APIUrl = c.Global.TelegramAPIUrl
}
}

names[rcv.Name] = struct{}{}
}

@@ -540,6 +550,7 @@ func DefaultGlobalConfig() GlobalConfig {
OpsGenieAPIURL: mustParseURL("https://api.opsgenie.com/"),
WeChatAPIURL: mustParseURL("https://qyapi.weixin.qq.com/cgi-bin/"),
VictorOpsAPIURL: mustParseURL("https://alert.victorops.com/integrations/generic/20131114/alert/"),
TelegramAPIUrl: mustParseURL("https://api.telegram.org"),
}
}

@@ -660,6 +671,7 @@ type GlobalConfig struct {
WeChatAPICorpID string `yaml:"wechat_api_corp_id,omitempty" json:"wechat_api_corp_id,omitempty"`
VictorOpsAPIURL *URL `yaml:"victorops_api_url,omitempty" json:"victorops_api_url,omitempty"`
VictorOpsAPIKey Secret `yaml:"victorops_api_key,omitempty" json:"victorops_api_key,omitempty"`
TelegramAPIUrl *URL `yaml:"telegram_api_url,omitempty" json:"telegram_api_url,omitempty"`
}

// UnmarshalYAML implements the yaml.Unmarshaler interface for GlobalConfig.
@@ -799,6 +811,7 @@ type Receiver struct {
PushoverConfigs []*PushoverConfig `yaml:"pushover_configs,omitempty" json:"pushover_configs,omitempty"`
VictorOpsConfigs []*VictorOpsConfig `yaml:"victorops_configs,omitempty" json:"victorops_configs,omitempty"`
SNSConfigs []*SNSConfig `yaml:"sns_configs,omitempty" json:"sns_configs,omitempty"`
TelegramConfigs []*TelegramConfig `yaml:"telegram_configs,omitempty" json:"telegram_configs,omitempty"`
}

// UnmarshalYAML implements the yaml.Unmarshaler interface for Receiver.
3 changes: 3 additions & 0 deletions config/notifiers.go
Original file line number Diff line number Diff line change
@@ -637,6 +637,9 @@ func (c *SNSConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
type TelegramConfig struct {
NotifierConfig `yaml:",inline" json:",inline"`

HTTPConfig *commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"`

APIUrl *URL `yaml:"api_url" json:"api_url,omitempty"`
BotToken string `yaml:"bot_token,omitempty" json:"token,omitempty"`
timmilesdw marked this conversation as resolved.
Show resolved Hide resolved
ChatID int64 `yaml:"chat_id,omitempty" json:"chat,omitempty"`
DisableNotifications bool `yaml:"disable_notifications,omitempty" json:"disable_notifications,omitempty"`