do some rename

This commit is contained in:
Balakrishnan Balasubramanian 2022-12-23 23:50:09 -05:00
parent d6ba4236df
commit 454aaf8460

20
main.go
View File

@ -9,7 +9,7 @@ import (
"strings"
)
var api_token = "421791796:AAE4wPbcqfLP1GNeGR3RTBiyX16fCj3HPAM"
var apiToken = "421791796:AAE4wPbcqfLP1GNeGR3RTBiyX16fCj3HPAM"
func main() {
fmt.Println("vim-go")
@ -52,8 +52,8 @@ func main() {
if update.Message != nil {
go sendButtonAndDelete(update.Message.Chat.ID, update.Message.ID, update.Message.Text)
} else if update.CallbackQuery != nil {
answer_url := fmt.Sprintf("https://api.telegram.org/bot%s/answerCallbackQuery?callback_query_id=%stext=ok", api_token, update.CallbackQuery.ID)
resp, err := http.Get(answer_url)
answerUrl := fmt.Sprintf("https://api.telegram.org/bot%s/answerCallbackQuery?callback_query_id=%stext=ok", apiToken, update.CallbackQuery.ID)
resp, err := http.Get(answerUrl)
if err != nil {
log.Println(err)
return
@ -70,9 +70,9 @@ func main() {
log.Panic(http.ListenAndServe(fmt.Sprintf(":%v", port), nil))
}
func sendButtonAndDelete(chatId int, messageId int, text string) {
url := fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", api_token)
editReqFmt := `
func sendButtonAndDelete(chatID int, messageID int, text string) {
url := fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", apiToken)
sendMsgFmt := `
{
"chat_id": "%d",
"text": "ok",
@ -85,8 +85,8 @@ func sendButtonAndDelete(chatId int, messageId int, text string) {
]]
}
`
editReq := fmt.Sprintf(editReqFmt, chatId, text)
resp, err := http.Post(url, "application/json", strings.NewReader(editReq))
sendMsgReq := fmt.Sprintf(sendMsgFmt, chatID, text)
resp, err := http.Post(url, "application/json", strings.NewReader(sendMsgReq))
if err != nil {
log.Println(err)
return
@ -98,8 +98,8 @@ func sendButtonAndDelete(chatId int, messageId int, text string) {
return
}
log.Println(string(body))
delete_url := fmt.Sprintf("https://api.telegram.org/bot%s/deleteMessage?chat_id=%d&message_id=%d", api_token, chatId, messageId)
resp, err = http.Get(delete_url)
deleteUrl := fmt.Sprintf("https://api.telegram.org/bot%s/deleteMessage?chat_id=%d&message_id=%d", apiToken, chatID, messageID)
resp, err = http.Get(deleteUrl)
if err != nil {
log.Println(err)
return