/** * Builder class for creating Telegram inline keyboards * * @module builders/InlineKeyboardBuilder * @example * ```typescript * const keyboard = new InlineKeyboardBuilder() * .appendRows(2) * .appendTextButton('Button 1', 'callback_1', 0) * .appendUrlButton('Google', 'https://google.com', 1) * .build(); * * await api.sendMessage(chatId, 'Test', { reply_markup: keyboard }); * ``` */ import { InlineKeyboardMarkup, InlineKeyboardButton } from '../api/types/index.js'; /** * Builder for creating inline keyboards with fluent API * This object represents an inline keyboard that appears right next to the message it belongs to */ export declare class InlineKeyboardBuilder { private keyboard; /** * Creates a new InlineKeyboardBuilder instance * * @param inlineKeyboard - Initial keyboard structure (optional) */ constructor(inlineKeyboard?: Array>); /** * Append one or more rows to the keyboard * * @param number - Number of rows to append. If not specified, will append one row * @returns This builder instance for chaining */ appendRows(number?: number): this; /** * Insert one or more rows to the keyboard * * @param index - Number of position to insert rows (0-based). If not specified, rows will insert at the first position * @param number - Number of rows to append. If not specified, will insert one row * @returns This builder instance for chaining */ insertRows(index?: number, number?: number): this; /** * Delete a row from the keyboard * * @param index - Index of row to delete (0-based). If not specified, will delete the last row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ deleteRow(index?: number): this; /** * Remove a button from a specific row * * @param row - Number of row of button to delete (0-based). If not specified, will delete a button from the last row * @param column - Number of column of button to delete (0-based). If not specified, will delete the last button from the row * @returns This builder instance for chaining * @throws {TelegramValidationError} If the button or row does not exist */ deleteButton(row?: number, column?: number): this; /** * Insert a text button to inline keyboard * * @param text - Text label for the button * @param callbackData - Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes * @param row - Row number to insert button (0-based). If not specified, the button will insert to the last row * @param column - Number of column of button to insert (0-based). If not specified, the button will insert to the first position of the row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ insertTextButton(text: string, callbackData: string, row?: number, column?: number): this; /** * Append a text button to inline keyboard * * @param text - Text label for the button * @param callbackData - Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes * @param row - Row number to append button (0-based). If not specified, the button will append to the last row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ appendTextButton(text: string, callbackData: string, row?: number): this; /** * Insert an url button to inline keyboard * * @param text - Text label for the button * @param url - HTTP or tg:// url to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings * @param row - Row number to insert button (0-based). If not specified, the button will insert to the last row * @param column - Number of column of button to insert (0-based). If not specified, the button will insert to the first position of the row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ insertUrlButton(text: string, url: string, row?: number, column?: number): this; /** * Append an url button to inline keyboard * * @param text - Text label for the button * @param url - HTTP or tg:// url to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings * @param row - Row number to append button (0-based). If not specified, the button will append to the last row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ appendUrlButton(text: string, url: string, row?: number): this; /** * Add a pay button to inline keyboard * NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages * * @param text - Text label for the button * @returns This builder instance for chaining * @throws {TelegramValidationError} If there is a CallbackGame button already added */ addPayButton(text: string): this; /** * Add a callback game button to inline keyboard * NOTE: This type of button must always be the first button in the first row * * @param text - Text label for the button * @returns This builder instance for chaining * @throws {TelegramValidationError} If there is a Pay button already added */ addCallbackGameButton(text: string): this; /** * Insert a SwitchInlineQuery button to inline keyboard * * @param text - Text label for the button * @param switchInlineQuery - If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. Can be empty, in which case just the bot's username will be inserted * @param row - Row number to insert button (0-based). If not specified, the button will insert to the last row * @param column - Number of column of button to insert (0-based). If not specified, the button will insert to the first position of the row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ insertSwitchInlineQueryButton(text: string, switchInlineQuery?: string, row?: number, column?: number): this; /** * Append a SwitchInlineQuery button to inline keyboard * * @param text - Text label for the button * @param switchInlineQuery - If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. Can be empty, in which case just the bot's username will be inserted * @param row - Row number to append button (0-based). If not specified, the button will append to the last row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ appendSwitchInlineQueryButton(text: string, switchInlineQuery?: string, row?: number): this; /** * Insert a SwitchInlineQueryCurrentChat button to inline keyboard * * @param text - Text label for the button * @param switchInlineQueryCurrentChat - If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot's username will be inserted. This offers a quick way for the user to open your bot in inline mode in the same chat – good for selecting something from multiple options * @param row - Row number to insert button (0-based). If not specified, the button will insert to the last row * @param column - Number of column of button to insert (0-based). If not specified, the button will insert to the first position of the row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ insertSwitchInlineQueryCurrentChatButton(text: string, switchInlineQueryCurrentChat?: string, row?: number, column?: number): this; /** * Append a SwitchInlineQueryCurrentChat button to inline keyboard * * @param text - Text label for the button * @param switchInlineQueryCurrentChat - If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot's username will be inserted. This offers a quick way for the user to open your bot in inline mode in the same chat – good for selecting something from multiple options * @param row - Row number to append button (0-based). If not specified, the button will append to the last row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ appendSwitchInlineQueryCurrentChatButton(text: string, switchInlineQueryCurrentChat?: string, row?: number): this; /** * Insert a LoginUrl button to inline keyboard * * @param text - Text label for the button * @param url - An HTTP URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data. NOTE: You must always check the hash of the received data to verify the authentication and the integrity of the data as described in Checking authorization * @param forwardText - New text of the button in forwarded messages * @param botUsername - Username of a bot, which will be used for user authorization. See Setting up a bot for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details * @param requestWriteAccess - Pass True to request the permission for your bot to send messages to the user * @param row - Row number to insert button (0-based). If not specified, the button will insert to the last row * @param column - Number of column of button to insert (0-based). If not specified, the button will insert to the first position of the row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ insertLoginUrlButton(text: string, url: string, forwardText?: string, botUsername?: string, requestWriteAccess?: boolean, row?: number, column?: number): this; /** * Append a LoginUrl button to inline keyboard * * @param text - Text label for the button * @param url - An HTTP URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data. NOTE: You must always check the hash of the received data to verify the authentication and the integrity of the data as described in Checking authorization * @param forwardText - New text of the button in forwarded messages * @param botUsername - Username of a bot, which will be used for user authorization. See Setting up a bot for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details * @param requestWriteAccess - Pass True to request the permission for your bot to send messages to the user * @param row - Row number to append button (0-based). If not specified, the button will append to the last row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ appendLoginUrlButton(text: string, url: string, forwardText?: string, botUsername?: string, requestWriteAccess?: boolean, row?: number): this; /** * Delete all buttons with the specified text from the keyboard * * @param text - The text to search for and delete * @returns This builder instance for chaining */ deleteButtonWithText(text: string): this; /** * Delete all buttons with the specified callback data from the keyboard * * @param callbackData - The callback data to search for and delete * @returns This builder instance for chaining */ deleteButtonWithCallbackData(callbackData: string): this; /** * Insert a WebApp button to inline keyboard * * @param text - Text label for the button * @param url - An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps * @param row - Row number to insert button (0-based). If not specified, the button will insert to the last row * @param column - Number of column of button to insert (0-based). If not specified, the button will insert to the first position of the row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ insertWebAppButton(text: string, url: string, row?: number, column?: number): this; /** * Append a WebApp button to inline keyboard * * @param text - Text label for the button * @param url - An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps * @param row - Row number to append button (0-based). If not specified, the button will append to the last row * @returns This builder instance for chaining * @throws {TelegramValidationError} If keyboard row does not exist */ appendWebAppButton(text: string, url: string, row?: number): this; /** * Checks if the keyboard contains a button with the specified text * * @param text - The text to search for in the keyboard buttons * @returns True if a button with the specified text is found, false otherwise */ hasButtonWithText(text: string): boolean; /** * Build and return the final InlineKeyboardMarkup object * * @returns The constructed InlineKeyboardMarkup object */ build(): InlineKeyboardMarkup; /** * Get the raw keyboard array (useful for debugging or advanced manipulation) * * @returns The internal keyboard array */ getRawKeyboard(): Array>; }