func SendTelegram(msg string) {
//生成要访问的url
botid := "1234"
bottoken := "abcd"
chatid := "5678"
url_api := "https://api.telegram.org/"
url_full := url_api + "bot" + botid + ":" + bottoken + "/sendMessage"
data := url.Values{"chat_id": {chatid}, "text": {msg}}
//proxy
if global.EnableHttpProxy {
global.HTTPClient = util.SetHttpProxy()
}
resp, err := global.HTTPClient.Post(url_full,
"application/x-www-form-urlencoded",
strings.NewReader(data.Encode()))
if err != nil {
log.Println(err)
}
defer resp.Body.Close()
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
}
}