Class InlineKeyboardButton

java.lang.Object
io.github.natanimn.telebof.types.keyboard.InlineKeyboardButton
All Implemented Interfaces:
Serializable

public class InlineKeyboardButton extends Object implements Serializable
This object represents one button of an inline keyboard. Exactly one of the optional fields must be used to specify type of the button.
Since:
3 March 2025
See Also:
  • Constructor Details

    • InlineKeyboardButton

      public InlineKeyboardButton(String text)
      Required
      Parameters:
      text - Label text on the button
    • InlineKeyboardButton

      public InlineKeyboardButton(String text, String callbackData)
      Parameters:
      text - Required. Label text on the button
      callbackData - Optional. Data to be sent in a callback query to the bot when the button is pressed, 1-64 bytes
  • Method Details

    • setUrl

      public InlineKeyboardButton setUrl(String url)
      Optional
      Parameters:
      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 identifier without using a username, if this is allowed by their privacy settings.
      Returns:
      InlineKeyboardButton
    • setWebApp

      public InlineKeyboardButton setWebApp(WebAppInfo webApp)
      Optional
      Parameters:
      webApp - Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot. Not supported for messages sent on behalf of a Telegram Business account.
      Returns:
      InlineKeyboardButton
    • setLoginUrl

      public InlineKeyboardButton setLoginUrl(LoginUrl loginUrl)
      Optional
      Parameters:
      loginUrl - An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget.
      Returns:
      InlineKeyboardButton
    • setSwitchInlineQueryCurrentChat

      public InlineKeyboardButton setSwitchInlineQueryCurrentChat(String switchInlineQueryCurrentChat)
      Optional
      Parameters:
      switchInlineQueryCurrentChat - If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username will be inserted.
      Returns:
      InlineKeyboardButton
    • setCallbackGame

      public InlineKeyboardButton setCallbackGame(CallbackGame callbackGame)
      Optional
      Parameters:
      callbackGame - Description of the game that will be launched when the user presses the button.
      NOTE: This type of button must always be the first button in the first row.
      Returns:
      InlineKeyboardButton
    • setPay

      public InlineKeyboardButton setPay(Boolean pay)
      Optional
      Parameters:
      pay - Specify True, to send a Pay button. Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon.
      NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages.
      Returns:
      InlineKeyboardButton
    • setSwitchInlineQueryChosenChat

      public InlineKeyboardButton setSwitchInlineQueryChosenChat(SwitchInlineQueryChosenChat switchInlineQueryChosenChat)
      Optional
      Parameters:
      switchInlineQueryChosenChat - If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. Not supported for messages sent on behalf of a Telegram Business account.
      Returns:
      InlineKeyboardButton
    • setCopyText

      public InlineKeyboardButton setCopyText(CopyTextButton copyText)
      Optional.
      Parameters:
      copyText - Description of the button that copies the specified text to the clipboard.
      Returns:
      InlineKeyboardButton
    • getText

      public String getText()
    • getUrl

      public String getUrl()
    • getCallbackData

      public String getCallbackData()
    • getSwitchInlineQueryCurrentChat

      public String getSwitchInlineQueryCurrentChat()
    • getWepApp

      public WebAppInfo getWepApp()
    • getLoginUrl

      public LoginUrl getLoginUrl()
    • getPay

      public Boolean getPay()
    • getCallbackGame

      public CallbackGame getCallbackGame()
    • getSwitchInlineQueryChosenChat

      public SwitchInlineQueryChosenChat getSwitchInlineQueryChosenChat()
    • getCopyText

      public CopyTextButton getCopyText()