Skip to content

Commit

Permalink
telegram additional description and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterlong committed Jun 27, 2020
1 parent 507c42f commit 3330161
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Added core.Example() function for testing
- Added Custom oAuth Authentication method
- Fixed setup form not creating user from values inputted in form
- Fixed issues with Telegram Notifier

# 0.90.55 (06-18-2020)
- Added 404 page
Expand Down
15 changes: 7 additions & 8 deletions notifiers/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ var Telegram = &telegram{&notifications.Notification{
Required: true,
}, {
Type: "text",
Title: "Channel or User",
Title: "Channel",
Placeholder: "@statping_channel",
SmallText: "Insert your Telegram Channel or User here.",
SmallText: "Insert your Telegram Channel including the @ symbol. The bot will need to be an administrator of this channel.",
DbField: "var1",
Required: true,
}}},
Expand All @@ -60,9 +60,8 @@ func (t *telegram) sendMessage(message string) (string, error) {
v := url.Values{}
v.Set("chat_id", t.Var1)
v.Set("text", message)
rb := *strings.NewReader(v.Encode())

contents, _, err := utils.HttpRequest(apiEndpoint, "GET", "application/x-www-form-urlencoded", nil, &rb, time.Duration(10*time.Second), true, nil)
contents, _, err := utils.HttpRequest(apiEndpoint, "POST", "application/x-www-form-urlencoded", nil, strings.NewReader(v.Encode()), time.Duration(10*time.Second), true, nil)

success, _ := telegramSuccess(contents)
if !success {
Expand All @@ -89,14 +88,14 @@ func (t *telegram) OnSuccess(s services.Service) (string, error) {

// OnTest will test the Twilio SMS messaging
func (t *telegram) OnTest() (string, error) {
msg := fmt.Sprintf("Testing the Twilio SMS Notifier on your Statping server")
content, err := t.sendMessage(msg)
return content, err
msg := fmt.Sprintf("Testing the Telegram Notifier on your Statping server")
return t.sendMessage(msg)
}

// OnSave will trigger when this notifier is saved
func (t *telegram) OnSave() (string, error) {
return "", nil
msg := fmt.Sprintf("The Telegram Notifier on your Statping server was just saved")
return t.sendMessage(msg)
}

func telegramSuccess(res []byte) (bool, telegramResponse) {
Expand Down

0 comments on commit 3330161

Please sign in to comment.