/** * Builder class for creating Telegram reply keyboards * * @module builders/ReplyKeyboardBuilder * @example * ```typescript * const keyboard = new ReplyKeyboardBuilder() * .appendRows(2) * .appendTextButton('Button 1', 0) * .appendTextButton('Button 2', 1) * .setResizeKeyboard(true) * .setOneTimeKeyboard(true) * .build(); * * await api.sendMessage(chatId, 'Test', { reply_markup: keyboard }); * ``` */ import { ReplyKeyboardMarkup, KeyboardButton } from '../api/types/index.js'; /** * Poll type options for request poll buttons */ export declare const KeyboardButtonPollType: { readonly QUIZ: "quiz"; readonly REGULAR: "regular"; readonly ANY: "any"; }; export type KeyboardButtonPollType = typeof KeyboardButtonPollType[keyof typeof KeyboardButtonPollType]; /** * Builder for creating reply keyboards with fluent API * This object represents a custom keyboard with reply options */ export declare class ReplyKeyboardBuilder { private keyboard; private isPersistent?; private resizeKeyboard?; private oneTimeKeyboard?; private inputFieldPlaceholder?; private selective?; /** * Creates a new ReplyKeyboardBuilder instance * * @param keyboard - Initial keyboard structure (optional) */ constructor(keyboard?: 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 reply keyboard * * @param text - Text label for the button * @param row - Row number to insert button (0-based). If not specified, the button will insert to the first 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, row?: number, column?: number): this; /** * Append a text button to reply keyboard * * @param text - Text label for the button * @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, row?: number): this; /** * Insert a request contact button to reply keyboard * * @param text - Text label for the button * @param row - Row number to insert button (0-based). If not specified, the button will insert to the first 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 */ insertRequestContactButton(text: string, row?: number, column?: number): this; /** * Append a request contact button to reply keyboard * * @param text - Text label for the button * @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 */ appendRequestContactButton(text: string, row?: number): this; /** * Insert a request location button to reply keyboard * * @param text - Text label for the button * @param row - Row number to insert button (0-based). If not specified, the button will insert to the first 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 */ insertRequestLocationButton(text: string, row?: number, column?: number): this; /** * Append a request location button to reply keyboard * * @param text - Text label for the button * @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 */ appendRequestLocationButton(text: string, row?: number): this; /** * Insert a Web App button to reply 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 first 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 Web App button to reply 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; /** * Insert a request poll button to reply keyboard * * @param text - Text label for the button * @param pollType - If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only * @param row - Row number to insert button (0-based). If not specified, the button will insert to the first 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 */ insertRequestPollButton(text: string, pollType?: KeyboardButtonPollType, row?: number, column?: number): this; /** * Append a request poll button to reply keyboard * * @param text - Text label for the button * @param pollType - If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only * @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 */ appendRequestPollButton(text: string, pollType?: KeyboardButtonPollType, 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; /** * 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; /** * Set the is_persistent property * Requests clients to always show the keyboard when the regular keyboard is hidden * * @param isPersistent - True to always show the keyboard * @returns This builder instance for chaining */ setIsPersistent(isPersistent: boolean): this; /** * Set the resize_keyboard property * Requests clients to resize the keyboard vertically for optimal fit * * @param resizeKeyboard - True to resize the keyboard * @returns This builder instance for chaining */ setResizeKeyboard(resizeKeyboard: boolean): this; /** * Set the one_time_keyboard property * Requests clients to hide the keyboard as soon as it's been used * * @param oneTimeKeyboard - True for one-time keyboard * @returns This builder instance for chaining */ setOneTimeKeyboard(oneTimeKeyboard: boolean): this; /** * Set the input_field_placeholder property * The placeholder to be shown in the input field when the keyboard is active * * @param placeholder - Placeholder text (1-64 characters) * @returns This builder instance for chaining */ setInputFieldPlaceholder(placeholder: string): this; /** * Set the selective property * Use this parameter if you want to show the keyboard to specific users only * * @param selective - True to show keyboard selectively * @returns This builder instance for chaining */ setSelective(selective: boolean): this; /** * Build and return the final ReplyKeyboardMarkup object * * @returns The constructed ReplyKeyboardMarkup object */ build(): ReplyKeyboardMarkup; /** * Get the raw keyboard array (useful for debugging or advanced manipulation) * * @returns The internal keyboard array */ getRawKeyboard(): Array>; }