Меню с кнопками

Messages
1,679
Reaction score
288
Website
tehadm.ru
C-like:
func main() {
    //... previous setup

    for update := range updates {
        if update.Message != nil {
            switch update.Message.Text {
            case "/start":
                msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Welcome! Choose an option:")
                inlineKeyboard := tgbotapi.NewInlineKeyboardMarkup(
                    tgbotapi.NewInlineKeyboardRow(
                        tgbotapi.NewInlineKeyboardButtonData("Option 1", "command1"),
                        tgbotapi.NewInlineKeyboardButtonData("Option 2", "command2"),
                    ),
                )
                msg.ReplyMarkup = inlineKeyboard
                bot.Send(msg)
            }
        } else if update.CallbackQuery != nil {
            var responseText string
            switch update.CallbackQuery.Data {
            case "command1":
                responseText = "You chose option 1"
            case "command2":
                responseText = "You chose option 2"
            }
            msg := tgbotapi.NewMessage(update.CallbackQuery.Message.Chat.ID, responseText)
            bot.Send(msg)
        }
    }
}
 
Back
Top