Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Fixed telegram notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmarmour committed Sep 26, 2020
1 parent d551bae commit e0a9267
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/alert/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ import (

//SendTelegramMessage Sends a notification message to a Telegram Webhook.
func SendTelegramMessage(item string, nvidiaURL string, config config.TelegramConfig, client *http.Client) error {
body := map[string]string{"Text": item + " Ready for Purchase: " + nvidiaURL, "ChatID": config.ChatID}
text := item + " Ready for Purchase: " + nvidiaURL
body := map[string]interface{}{"chat_id": config.ChatID, "text": text, "disable_web_page_preview": true}

payload, err := json.Marshal(body)
if err != nil {
return err
}

// We're required to disable web page previews to ensure that the cart links don't get invalidated
req, err := http.NewRequest("POST", fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage&disable_web_page_preview=true", config.APIKey), bytes.NewBuffer(payload))
req, err := http.NewRequest("POST", fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", config.APIKey), bytes.NewBuffer(payload))
if err != nil {
return err
}

req.Header.Add("Content-Type", "application/json")
req.Header.Set("content-type", "application/json")

r, err := client.Do(req)
if err != nil {
Expand Down

0 comments on commit e0a9267

Please sign in to comment.