Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ButtonClickParam

Interface for clicking a message button. Calls SendVote with the specified poll option or button.click <MessageButton.click> on the specified button. Does nothing if the message is not a poll or has no buttons.

example
   # Click the first button
await message.click(0)

# Click some row/column
await message.click(row, column)

# Click by text
await message.click(text='👍')

# Click by data
await message.click(data=b'payload')

# Click on a button requesting a phone
await message.click(0, share_phone=True)

Hierarchy

  • ButtonClickParam

Index

Properties

i?: number | number[]

Clicks the i'th button or poll option (starting from the index 0). For multiple-choice polls, a list with the indices should be used. Will raise IndexError if out of bounds. Example:

message = ... # get the message somehow

Clicking the 3rd button

[button1] [button2]

[ button3 ]

[button4] [button5]

await message.click(2) # index .

j?: number

Clicks the button at position (i, j), these being the indices for the (row, column) respectively. Example:

Clicking the 2nd button on the 1st row.

[button1] [button2]

[ button3 ]

[button4] [button5]

await message.click(0, 1) # (row, column)

This is equivalent to message.buttons[0][1].click().

text?: string | Function

Clicks the first button or poll option with the text "text". This may also be a callable, like a new RegExp('foo*').test, and the text will be passed to it.

If you need to select multiple options in a poll, pass a list of indices to the i parameter.

filter?: Function

Clicks the first button or poll option for which the callable returns True. The callable should accept a single MessageButton <messagebutton.MessageButton> or PollAnswer <PollAnswer> argument. If you need to select multiple options in a poll, pass a list of indices to the i parameter.

data?: Buffer

This argument overrides the rest and will not search any buttons. Instead, it will directly send the request to behave as if it clicked a button with said data. Note that if the message does not have this data, it will DATA_INVALID.

sharePhone?: string | boolean | InputMediaContact

When clicking on a keyboard button requesting a phone number (KeyboardButtonRequestPhone), this argument must be explicitly set to avoid accidentally sharing the number.

It can be true to automatically share the current user's phone, a string to share a specific phone number, or a contact media to specify all details.

If the button is pressed without this, new Error("Value Error") is raised.

shareGeo?: InputMediaGeoPoint | [number, number]

When clicking on a keyboard button requesting a geo location (KeyboardButtonRequestGeoLocation), this argument must be explicitly set to avoid accidentally sharing the location.

It must be a list of float as (longitude, latitude), or a :tl:InputGeoPoint instance to avoid accidentally using the wrong roder.

If the button is pressed without this, ValueError is raised.

password?: string

When clicking certain buttons (such as BotFather's confirmation button to transfer ownership), if your account has 2FA enabled, you need to provide your account's password. Otherwise, PASSWORD_HASH_INVALID is raised.

Generated using TypeDoc