Module telegram-bot-lua.builders

keyboard and inline markup builders.

Functions

api.callback_data_button(text, callback_data, encoded) create a standalone callback data inline keyboard button.
api.callback_game_button(text, callback_game, encoded) create a standalone callback game inline keyboard button.
api.inline_keyboard() create an inline keyboard markup with a chainable builder pattern.
api.inline_keyboard_meta:row(row) add a row of buttons to the inline keyboard.
api.input_media_photo(media, caption, parse_mode) create an input media photo object for use with sendMediaGroup and editMessageMedia.
api.input_media_video(media, thumbnail, caption, parse_mode, width, height, duration, supports_streaming) create an input media video object for use with sendMediaGroup and editMessageMedia.
api.keyboard(resize_keyboard, one_time_keyboard, selective) create a reply keyboard markup with a chainable builder pattern.
api.keyboard_meta:row(row) add a row of buttons to the reply keyboard.
api.labeled_price(label, amount, encoded) create a standalone labelled price object for payment invoices.
api.mask_position() create a mask position array with a chainable builder pattern.
api.mask_position_meta:position(point, x_shift, y_shift, scale) add a mask position entry specifying where a mask should be placed on a face.
api.pay_button(text, pay, encoded) create a standalone pay inline keyboard button.
api.prices() create a prices array with a chainable builder pattern for payment invoices.
api.prices_meta:labeled_price(label, amount) add a labelled price to the prices array.
api.remove_keyboard(selective) create a remove keyboard markup to request removal of the custom keyboard.
api.row(_) create a row of inline keyboard buttons with a chainable builder pattern.
api.row_meta:callback_data_button(text, callback_data) add a callback data button to the row.
api.row_meta:pay_button(text, pay) add a pay button to the row.
api.row_meta:switch_inline_query_button(text, switch_inline_query) add a switch inline query button to the row.
api.row_meta:switch_inline_query_current_chat_button(text, switch_inline_query_current_chat) add a switch inline query current chat button to the row.
api.row_meta:url_button(text, url) add a url button to the row.
api.shipping_options() create a shipping options array with a chainable builder pattern.
api.shipping_options_meta:shipping_option(id, title, prices) add a shipping option to the shipping options array.
api.switch_inline_query_button(text, switch_inline_query, encoded) create a standalone switch inline query button.
api.switch_inline_query_current_chat_button(text, switch_inline_query_current_chat, encoded) create a standalone switch inline query current chat button.
api.url_button(text, url, encoded) create a standalone url inline keyboard button.


Functions

api.callback_data_button(text, callback_data, encoded)
create a standalone callback data inline keyboard button.

Parameters:

  • text string label text for the button
  • callback_data string data to be sent in a callback query when pressed
  • encoded boolean optional json-encode the result

Returns:

    table|string|boolean the button object, json string if encoded, or false on missing params
api.callback_game_button(text, callback_game, encoded)
create a standalone callback game inline keyboard button.

Parameters:

  • text string label text for the button
  • callback_game string description of the game to be launched
  • encoded boolean optional json-encode the result

Returns:

    table|string|boolean the button object, json string if encoded, or false on missing params
api.inline_keyboard()
create an inline keyboard markup with a chainable builder pattern.

Returns:

    table an inline keyboard markup object with metatable for chaining
api.inline_keyboard_meta:row(row)
add a row of buttons to the inline keyboard.

Parameters:

  • row table a row of inline keyboard button objects

Returns:

    table self for chaining
api.input_media_photo(media, caption, parse_mode)
create an input media photo object for use with sendMediaGroup and editMessageMedia.

Parameters:

  • media string file_id, url, or file path for the photo
  • caption string optional caption for the photo
  • parse_mode string optional parse mode for the caption ("MarkdownV2", "HTML", etc.)

Returns:

    table,table the input media object and a table of file references
api.input_media_video(media, thumbnail, caption, parse_mode, width, height, duration, supports_streaming)
create an input media video object for use with sendMediaGroup and editMessageMedia.

Parameters:

  • media string file_id, url, or file path for the video
  • thumbnail string optional thumbnail file_id or file path
  • caption string optional caption for the video
  • parse_mode string optional parse mode for the caption
  • width number optional video width
  • height number optional video height
  • duration number optional video duration in seconds
  • supports_streaming boolean optional whether the video is suitable for streaming

Returns:

    table,table the input media object and a table of file references
api.keyboard(resize_keyboard, one_time_keyboard, selective)
create a reply keyboard markup with a chainable builder pattern.

Parameters:

  • resize_keyboard boolean optional request to resize the keyboard vertically
  • one_time_keyboard boolean optional request to hide the keyboard after use
  • selective boolean optional show keyboard to specific users only

Returns:

    table a reply keyboard markup object with metatable for chaining
api.keyboard_meta:row(row)
add a row of buttons to the reply keyboard.

Parameters:

  • row table a row of keyboard button objects

Returns:

    table self for chaining
api.labeled_price(label, amount, encoded)
create a standalone labelled price object for payment invoices.

Parameters:

  • label string price label, e.g. "product price"
  • amount number price in the smallest units of the currency
  • encoded boolean optional json-encode the result

Returns:

    table|string|boolean the labelled price object, json string if encoded, or false on invalid params
api.mask_position()
create a mask position array with a chainable builder pattern.

Returns:

    table a mask position array object with metatable for chaining
api.mask_position_meta:position(point, x_shift, y_shift, scale)
add a mask position entry specifying where a mask should be placed on a face.

Parameters:

  • point string the part of the face to place the mask on ("forehead", "eyes", "mouth", or "chin")
  • x_shift number shift by x-axis measured in widths of the mask
  • y_shift number shift by y-axis measured in heights of the mask
  • scale number mask scaling coefficient

Returns:

    table self for chaining
api.pay_button(text, pay, encoded)
create a standalone pay inline keyboard button.

Parameters:

  • text string label text for the button
  • pay boolean whether this is a pay button
  • encoded boolean optional json-encode the result

Returns:

    table|string|boolean the button object, json string if encoded, or false on missing params
api.prices()
create a prices array with a chainable builder pattern for payment invoices.

Returns:

    table a prices array object with metatable for chaining
api.prices_meta:labeled_price(label, amount)
add a labelled price to the prices array.

Parameters:

  • label string price label, e.g. "product price"
  • amount number price in the smallest units of the currency

Returns:

    table self for chaining
api.remove_keyboard(selective)
create a remove keyboard markup to request removal of the custom keyboard.

Parameters:

  • selective boolean optional remove keyboard for specific users only

Returns:

    table a ReplyKeyboardRemove object
api.row(_)
create a row of inline keyboard buttons with a chainable builder pattern.

Parameters:

  • _

Returns:

    table a row object with metatable for chaining button additions
api.row_meta:callback_data_button(text, callback_data)
add a callback data button to the row.

Parameters:

  • text string label text for the button
  • callback_data string data to be sent in a callback query when the button is pressed

Returns:

    table self for chaining
api.row_meta:pay_button(text, pay)
add a pay button to the row.

Parameters:

  • text string label text for the button
  • pay boolean whether this is a pay button

Returns:

    table self for chaining
api.row_meta:switch_inline_query_button(text, switch_inline_query)
add a switch inline query button to the row.

Parameters:

  • text string label text for the button
  • switch_inline_query string query to insert into the chat input when switching to inline mode

Returns:

    table self for chaining
api.row_meta:switch_inline_query_current_chat_button(text, switch_inline_query_current_chat)
add a switch inline query current chat button to the row.

Parameters:

  • text string label text for the button
  • switch_inline_query_current_chat string query to insert into the current chat input for inline mode

Returns:

    table self for chaining
api.row_meta:url_button(text, url)
add a url button to the row.

Parameters:

  • text string label text for the button
  • url string http or tg:// url to open when the button is pressed

Returns:

    table self for chaining
api.shipping_options()
create a shipping options array with a chainable builder pattern.

Returns:

    table a shipping options array object with metatable for chaining
api.shipping_options_meta:shipping_option(id, title, prices)
add a shipping option to the shipping options array.

Parameters:

  • id string unique identifier for the shipping option
  • title string display name for the shipping option
  • prices table array of labelled price objects for this option

Returns:

    table self for chaining
api.switch_inline_query_button(text, switch_inline_query, encoded)
create a standalone switch inline query button.

Parameters:

  • text string label text for the button
  • switch_inline_query string query to insert when switching to inline mode in another chat
  • encoded boolean optional json-encode the result

Returns:

    table|string|boolean the button object, json string if encoded, or false on missing params
api.switch_inline_query_current_chat_button(text, switch_inline_query_current_chat, encoded)
create a standalone switch inline query current chat button.

Parameters:

  • text string label text for the button
  • switch_inline_query_current_chat string query to insert into the current chat for inline mode
  • encoded boolean optional json-encode the result

Returns:

    table|string|boolean the button object, json string if encoded, or false on missing params
api.url_button(text, url, encoded)
create a standalone url inline keyboard button.

Parameters:

  • text string label text for the button
  • url string http or tg:// url to open when the button is pressed
  • encoded boolean optional json-encode the result

Returns:

    table|string|boolean the button object, json string if encoded, or false on missing params
generated by LDoc 1.5.0 Last updated 2026-04-07 21:37:15