Class Keyboard

Represents a custom keyboard for Telegram bots.

Constructors

Properties

inputFieldPlaceholder?: string

The placeholder text for the input field.

isPersistent: boolean

Indicates whether the keyboard is persistent.

keyboard: KeyboardButton[][]
oneTimeKeyboard: boolean

Indicates whether the keyboard is a one-time keyboard.

resizeKeyboard: 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.

  • Checks if this keyboard is equal to another keyboard.

    Parameters

    • other: Keyboard

      The other keyboard to compare with.

    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.