go-telegram-bot-api / telegram-bot-api

Golang bindings for the Telegram Bot API
https://go-telegram-bot-api.dev
MIT License
5.75k stars 887 forks source link

InlineKeyboardButton web_app #698

Open zy2203 opened 8 months ago

zy2203 commented 8 months ago

At InlineKeyboardButton, has field web_app, but here not have.

dpominov commented 7 months ago

You can make a web app button this way:

msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Hi")
msg.ReplyMarkup = tgbotapi.NewInlineKeyboardMarkup(
    tgbotapi.NewInlineKeyboardRow(
        tgbotapi.NewInlineKeyboardButtonWebApp("My WebApp", tgbotapi.WebAppInfo{URL: WEBAPP_URL}),
    ),
)

You can also add a web app button to the chat menu:

mb = &tgbotapi.MenuButton{
    Type:   "web_app",
    Text:   "My WebApp",
    WebApp: &tgbotapi.WebAppInfo{URL: WEBAPP_URL},
}

_, err := ba.Request(tgbotapi.SetChatMenuButtonConfig{MenuButton: mb})
rays1410 commented 6 months ago

If you wondering why you do not have WebApp related stuff in your version of library, you should try to install the master's version, not the latest tag. Use go get -u github.com/go-telegram-bot-api/telegram-bot-api/v5@master

monoflash commented 2 months ago

When is the WebApp planned to be released?

hyonosake commented 2 months ago

@rays1410 y ist that so tho..? 😞

Took me a while to come up with that

song-without-words commented 1 month ago

You can make a web app button this way:

msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Hi")
msg.ReplyMarkup = tgbotapi.NewInlineKeyboardMarkup(
  tgbotapi.NewInlineKeyboardRow(
      tgbotapi.NewInlineKeyboardButtonWebApp("My WebApp", tgbotapi.WebAppInfo{URL: WEBAPP_URL}),
  ),
)

You can also add a web app button to the chat menu:

mb = &tgbotapi.MenuButton{
  Type:   "web_app",
  Text:   "My WebApp",
  WebApp: &tgbotapi.WebAppInfo{URL: WEBAPP_URL},
}

_, err := ba.Request(tgbotapi.SetChatMenuButtonConfig{MenuButton: mb})

You can make a web app button this way:

msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Hi")
msg.ReplyMarkup = tgbotapi.NewInlineKeyboardMarkup(
  tgbotapi.NewInlineKeyboardRow(
      tgbotapi.NewInlineKeyboardButtonWebApp("My WebApp", tgbotapi.WebAppInfo{URL: WEBAPP_URL}),
  ),
)

You can also add a web app button to the chat menu:

mb = &tgbotapi.MenuButton{
  Type:   "web_app",
  Text:   "My WebApp",
  WebApp: &tgbotapi.WebAppInfo{URL: WEBAPP_URL},
}

_, err := ba.Request(tgbotapi.SetChatMenuButtonConfig{MenuButton: mb})

Sorry, I can't find the MenuButton

dpominov commented 1 month ago

Sorry, I can't find the MenuButton

Use master branch https://github.com/go-telegram-bot-api/telegram-bot-api/issues/698#issuecomment-2016949865