mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Update Deps, fix staticcheck and golint warnings (#2558)
This commit is contained in:
@@ -10,11 +10,11 @@ import (
|
||||
|
||||
func init() {
|
||||
initers = append(initers, func(cfg map[string]string) Notifier {
|
||||
if bot_token, ok := cfg["telegram_bot_token"]; ok {
|
||||
if chat_id, ok := cfg["telegram_chat_id"]; ok {
|
||||
if botToken, ok := cfg["telegram_bot_token"]; ok {
|
||||
if chatID, ok := cfg["telegram_chat_id"]; ok {
|
||||
notifier := &telegramNotifier{
|
||||
BOT_TOKEN: bot_token,
|
||||
CHAT_ID: chat_id,
|
||||
BotToken: botToken,
|
||||
ChatID: chatID,
|
||||
}
|
||||
return notifier
|
||||
}
|
||||
@@ -25,8 +25,8 @@ func init() {
|
||||
|
||||
// telegramNotifier sends notifications to Telegram
|
||||
type telegramNotifier struct {
|
||||
BOT_TOKEN string
|
||||
CHAT_ID string
|
||||
BotToken string
|
||||
ChatID string
|
||||
}
|
||||
|
||||
func (s *telegramNotifier) Notify(domain, provider, msg string, err error, preview bool) {
|
||||
@@ -35,9 +35,9 @@ func (s *telegramNotifier) Notify(domain, provider, msg string, err error, previ
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
var url = fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", s.BOT_TOKEN)
|
||||
var url = fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", s.BotToken)
|
||||
|
||||
payload.ChatID, _ = strconv.ParseInt(s.CHAT_ID, 10, 64)
|
||||
payload.ChatID, _ = strconv.ParseInt(s.ChatID, 10, 64)
|
||||
|
||||
if preview {
|
||||
payload.Text = fmt.Sprintf(`DNSControl preview: %s[%s] -** %s`, domain, provider, msg)
|
||||
@@ -47,9 +47,9 @@ func (s *telegramNotifier) Notify(domain, provider, msg string, err error, previ
|
||||
payload.Text = fmt.Sprintf(`DNSControl successfully ran correction for **%s[%s]** - %s`, domain, provider, msg)
|
||||
}
|
||||
|
||||
marshaled_payload, _ := json.Marshal(payload)
|
||||
marshaledPayload, _ := json.Marshal(payload)
|
||||
|
||||
_, _ = http.Post(url, "application/json", bytes.NewBuffer(marshaled_payload))
|
||||
_, _ = http.Post(url, "application/json", bytes.NewBuffer(marshaledPayload))
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user