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