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

InlineKeyboardButton web_app

zy2203 opened this issue · 6 comments

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

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})

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

When is the WebApp planned to be released?

@rays1410 y ist that so tho..? 😞

Took me a while to come up with that

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

Sorry, I can't find the MenuButton

Use master branch #698 (comment)