import { InlineKeyboard } from "https://dotland.deno.dev/x/grammy@v1.15.2/convenience/keyboard.ts";
Use this class to simplify building an inline keyboard (something like this: https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating).
// Build an inline keyboard:
const keyboard = new InlineKeyboard()
.text('A').text('B', 'callback-data').row()
.text('C').text('D').row()
.url('Telegram', 'telegram.org')
// Send the keyboard:
await ctx.reply('Here is your inline keyboard!', {
reply_markup: keyboard
})
Be sure to to check the documentation on inline keyboards in grammY.
Constructors
Initialize a new InlineKeyboard
with an optional two-dimensional array
of InlineKeyboardButton
objects. This is the nested array that holds
the inline keyboard. It will be extended every time you call one of the
provided methods.
Methods
Allows you to add your own InlineKeyboardButton
objects if you already
have them for some reason. You most likely want to call one of the other
methods.
Adds a new game query button, confer https://core.telegram.org/bots/api#games
This type of button must always be the first button in the first row.
Adds a new login button. This can be used as a replacement for the Telegram Login Widget. You must specify an HTTPS URL used to automatically authorize the user.
Adds a new payment button, confer https://core.telegram.org/bots/api#payments
This type of button must always be the first button in the first row and can only be used in invoice messages.
Adds a 'line break'. Call this method to make sure that the next added buttons will be on a new row.
You may pass a number of InlineKeyboardButton
objects if you already
have the instances for some reason. You most likely don't want to pass
any arguments to row
.
Adds a new inline query button. Telegram clients will let the user pick a chat when this button is pressed. This will start an inline query. The selected chat will be prefilled with the name of your bot. You may provide a text that is specified along with it.
Your bot will in turn receive updates for inline queries. You can listen to inline query updates like this:
bot.on('inline_query', ctx => { ... })
Adds a new inline query button that act on the current chat. The selected chat will be prefilled with the name of your bot. You may provide a text that is specified along with it. This will start an inline query.
Your bot will in turn receive updates for inline queries. You can listen to inline query updates like this:
bot.on('inline_query', ctx => { ... })
Adds a new callback query button. The button contains a text and a custom payload. This payload will be sent back to your bot when the button is pressed. If you omit the payload, the display text will be sent back to your bot.
Your bot will receive an update every time a user presses any of the text buttons. You can listen to these updates like this:
// Specific buttons:
bot.callbackQuery('button-data', ctx => { ... })
// Any button of any inline keyboard:
bot.on('callback_query:data', ctx => { ... })
Adds a new URL button. Telegram clients will open the provided URL when the button is pressed.
Adds a new web app button, confer https://core.telegram.org/bots/webapps