Skip to content

Commit

Permalink
Merge pull request #3 from SpEcHiDe/patch-1
Browse files Browse the repository at this point in the history
change GET to POST
  • Loading branch information
EverythingSuckz authored Oct 10, 2022
2 parents b39797c + fa584c7 commit 60f9b84
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions utils/telegram.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package utils

import (
"bytes"
"encoding/json"
"fmt"
"github-telegram-notify/types"
Expand All @@ -13,10 +14,11 @@ func SendMessage(token string, chatID string, text string, markupText string, ma
apiBaseUri, _ := url.Parse("https://api.telegram.org")
req_url, _ := url.Parse(fmt.Sprint(apiBaseUri, "/bot", token, "/sendMessage"))
params := url.Values{}
params.Set("chat_id", chatID)
params.Set("text", text)
params.Set("parse_mode", "html")
params.Set("disable_web_page_preview", "true")
params := map[string]string{}
params.["chat_id"] = chatID
params["text"] = text
params["parse_mode"] = "html"
params["disable_web_page_preview"] = "true"
kyb, err := json.Marshal(map[string][][]map[string]string{
"inline_keyboard": {
{{"text": markupText, "url": markupUrl}},
Expand All @@ -29,9 +31,16 @@ func SendMessage(token string, chatID string, text string, markupText string, ma
Message: err.Error(),
}
}
params.Set("reply_markup", string(kyb))
req_url.RawQuery = params.Encode()
resp, err := http.Get(req_url.String())
params["reply_markup"] = string(kyb)
json_data, err := json.Marshal(params)
if err != nil {
return types.Error{
Module: "json",
Description: "Failed to marshal request parameter",
Message: err.Error(),
}
}
resp, err := http.Post(req_url.String(), "application/json", bytes.NewBuffer(json_data))
if err != nil {
return types.Error{
Module: "http",
Expand Down

0 comments on commit 60f9b84

Please sign in to comment.