@@ -7,57 +7,57 @@ when you send "close" message.
77package main
88
99import (
10- " log"
11- " os"
10+ " log"
11+ " os"
1212
13- " github.com/go-telegram-bot-api/telegram-bot-api"
13+ tgbotapi " github.com/go-telegram-bot-api/telegram-bot-api/v5 "
1414)
1515
1616var numericKeyboard = tgbotapi.NewReplyKeyboard (
17- tgbotapi.NewKeyboardButtonRow (
18- tgbotapi.NewKeyboardButton (" 1" ),
19- tgbotapi.NewKeyboardButton (" 2" ),
20- tgbotapi.NewKeyboardButton (" 3" ),
21- ),
22- tgbotapi.NewKeyboardButtonRow (
23- tgbotapi.NewKeyboardButton (" 4" ),
24- tgbotapi.NewKeyboardButton (" 5" ),
25- tgbotapi.NewKeyboardButton (" 6" ),
26- ),
17+ tgbotapi.NewKeyboardButtonRow (
18+ tgbotapi.NewKeyboardButton (" 1" ),
19+ tgbotapi.NewKeyboardButton (" 2" ),
20+ tgbotapi.NewKeyboardButton (" 3" ),
21+ ),
22+ tgbotapi.NewKeyboardButtonRow (
23+ tgbotapi.NewKeyboardButton (" 4" ),
24+ tgbotapi.NewKeyboardButton (" 5" ),
25+ tgbotapi.NewKeyboardButton (" 6" ),
26+ ),
2727)
2828
2929func main () {
30- bot , err := tgbotapi.NewBotAPI (os.Getenv (" TELEGRAM_APITOKEN" ))
31- if err != nil {
32- log.Panic (err)
33- }
30+ bot , err := tgbotapi.NewBotAPI (os.Getenv (" TELEGRAM_APITOKEN" ))
31+ if err != nil {
32+ log.Panic (err)
33+ }
3434
35- bot.Debug = true
35+ bot.Debug = true
3636
37- log.Printf (" Authorized on account %s " , bot.Self .UserName )
37+ log.Printf (" Authorized on account %s " , bot.Self .UserName )
3838
39- u := tgbotapi.NewUpdate (0 )
40- u.Timeout = 60
39+ u := tgbotapi.NewUpdate (0 )
40+ u.Timeout = 60
4141
42- updates := bot.GetUpdatesChan (u)
42+ updates := bot.GetUpdatesChan (u)
4343
44- for update := range updates {
45- if update.Message == nil { // ignore non-Message updates
46- continue
47- }
44+ for update := range updates {
45+ if update.Message == nil { // ignore non-Message updates
46+ continue
47+ }
4848
49- msg := tgbotapi.NewMessage (update.Message .Chat .ID , update.Message .Text )
49+ msg := tgbotapi.NewMessage (update.Message .Chat .ID , update.Message .Text )
5050
51- switch update.Message .Text {
52- case " open" :
53- msg.ReplyMarkup = numericKeyboard
54- case " close" :
55- msg.ReplyMarkup = tgbotapi.NewRemoveKeyboard (true )
56- }
51+ switch update.Message .Text {
52+ case " open" :
53+ msg.ReplyMarkup = numericKeyboard
54+ case " close" :
55+ msg.ReplyMarkup = tgbotapi.NewRemoveKeyboard (true )
56+ }
5757
58- if _ , err := bot.Send (msg); err != nil {
59- log.Panic (err)
60- }
61- }
58+ if _ , err := bot.Send (msg); err != nil {
59+ log.Panic (err)
60+ }
61+ }
6262}
6363```
0 commit comments