Class KeyboardBuilder

Represents a custom keyboard for Telegram bots.

Constructors

Properties

input_field_placeholder?: string

The placeholder text for the input field.

is_persistent?: boolean

Indicates whether the keyboard is persistent.

keyboard: KeyboardButton[][]
one_time_keyboard?: boolean

Indicates whether the keyboard is a one-time keyboard.

resize_keyboard?: boolean

Indicates whether the keyboard should be resized.

selective?: boolean

Indicates whether the keyboard is selective.

Methods

  • Adds buttons to the last row of the keyboard.

    Parameters

    Returns this

    The current instance for chaining.

  • Creates a deep copy of the current Keyboard instance.

    Parameters

    Returns KeyboardBuilder

    A new instance of Keyboard with the same buttons and properties.

  • Checks if this keyboard is equal to another keyboard.

    Parameters

    Returns boolean

    True if both keyboards are equal based on their structure and properties, otherwise false.

  • Sets the keyboard as a one-time keyboard or not.

    Parameters

    • OptionalisEnabled: boolean

      Indicates whether the keyboard should be a one-time keyboard.

    Returns this

    The current instance for chaining.

  • Sets the keyboard as persistent or not.

    Parameters

    • OptionalisEnabled: boolean

      Indicates whether the keyboard should be persistent.

    Returns this

    The current instance for chaining.

  • Sets the placeholder text for the input field.

    Parameters

    • value: string

      The placeholder text.

    Returns this

    The current instance for chaining.

  • Adds a request chat button to the keyboard.

    Parameters

    • text: string

      The button text.

    • requestId: number

      The request ID.

    • Optionaloptions: Omit<KeyboardButtonRequestChat, "requestId">

      Additional options for the button.

    Returns this

    The current instance for chaining.

  • Adds a request contact button to the keyboard.

    Parameters

    • text: string

      The button text.

    Returns this

    The current instance for chaining.

  • Adds a request location button to the keyboard.

    Parameters

    • text: string

      The button text.

    Returns this

    The current instance for chaining.

  • Adds a request poll button to the keyboard.

    Parameters

    • text: string

      The button text.

    • Optionaltype: "quiz" | "regular"

      The type of the poll button.

    Returns this

    The current instance for chaining.

  • Adds a request users button to the keyboard.

    Parameters

    • text: string

      The button text.

    • requestId: number

      The request ID.

    • Optionaloptions: Omit<KeyboardButtonRequestUsers, "requestId">

      Additional options for the button.

    Returns this

    The current instance for chaining.

  • Sets the keyboard to be resized or not.

    Parameters

    • OptionalisEnabled: boolean

      Indicates whether the keyboard should be resized.

    Returns this

    The current instance for chaining.

  • Adds a new row of buttons to the keyboard.

    Parameters

    Returns this

    The current instance for chaining.

  • Sets the keyboard as selective or not.

    Parameters

    • OptionalisEnabled: boolean

      Indicates whether the keyboard should be selective.

    Returns this

    The current instance for chaining.

  • Adds a text button to the keyboard.

    Parameters

    • text: string

      The button text.

    Returns this

    The current instance for chaining.

  • Adds a web app button to the keyboard.

    Parameters

    • text: string

      The button text.

    • url: string

      The URL of the web app.

    Returns this

    The current instance for chaining.

  • Creates a request chat button.

    Parameters

    • text: string

      The button text.

    • requestId: number

      The request ID.

    • Optionaloptions: Omit<KeyboardButtonRequestChat, "requestId">

      Additional options for the button.

    Returns RequestChatButton

    The created request chat button.

  • Creates a request poll button.

    Parameters

    • text: string

      The button text.

    • Optionaltype: "quiz" | "regular"

      The type of the poll button.

    Returns RequestPollButton

    The created request poll button.

  • Creates a request users button.

    Parameters

    • text: string

      The button text.

    • requestId: number

      The request ID.

    • Optionaloptions: Omit<KeyboardButtonRequestUsers, "requestId">

      Additional options for the button.

    Returns RequestUsersButton

    The created request users button.

  • Creates a text button.

    Parameters

    • text: string

      The button text.

    Returns CommonButton

    The created text button.