InlineKeyboard
in package
implements
JsonSerializable
Builds the `InlineKeyboardMarkup` attached under a message - the buttons that stay with the message rather than replacing the user's keyboard.
$telegram->sendMessage($chatId, 'Deploy?', reply_markup: InlineKeyboard::new()
->callback('Ship it', 'deploy:yes')
->callback('Hold', 'deploy:no')
->row()
->url('What changed', 'https://example.com/diff'));
Buttons land in the current row; row() starts the next one.
Tags
Table of Contents
Interfaces
- JsonSerializable
Properties
- $rows : array<int, array<int, array<string, mixed>>>
Methods
- button() : self
- Adds a button built by hand, for the fields the named helpers do not cover.
- callback() : self
- A button that sends `callback_data` back as a callback query.
- copyText() : self
- A button that copies text to the user's clipboard.
- game() : self
- A button that opens a game. One per message, and it must be the first button.
-
jsonSerialize()
: array{inline_keyboard: list
- >>}
- login() : self
- A button that logs the user in to your site through Telegram.
- new() : self
- pay() : self
- The pay button for an invoice. One per message, and it must be the first button.
- row() : self
- Starts a new row. A row that would be left empty is dropped on serialisation.
- switchInline() : self
- A button that drops the bot's username and a query into a chat the user picks.
- url() : self
- A button that opens a URL.
- webApp() : self
- A button that launches a Mini App.
Properties
$rows
private
array<int, array<int, array<string, mixed>>>
$rows
= [[]]
Methods
button()
Adds a button built by hand, for the fields the named helpers do not cover.
public
button(array<string, mixed> $button) : self
Parameters
- $button : array<string, mixed>
Return values
selfcallback()
A button that sends `callback_data` back as a callback query.
public
callback(string $text, string $data) : self
Parameters
- $text : string
- $data : string
Return values
selfcopyText()
A button that copies text to the user's clipboard.
public
copyText(string $text, string $copy) : self
Parameters
- $text : string
- $copy : string
Return values
selfgame()
A button that opens a game. One per message, and it must be the first button.
public
game(string $text) : self
Parameters
- $text : string
Return values
selfjsonSerialize()
public
jsonSerialize() : array{inline_keyboard: list>>}
Return values
array{inline_keyboard: list- >>}
login()
A button that logs the user in to your site through Telegram.
public
login(string $text, string $url[, ?string $forwardText = null ][, ?string $botUsername = null ][, ?bool $requestWriteAccess = null ]) : self
Parameters
- $text : string
- $url : string
- $forwardText : ?string = null
- $botUsername : ?string = null
- $requestWriteAccess : ?bool = null
Return values
selfnew()
public
static new() : self
Return values
selfpay()
The pay button for an invoice. One per message, and it must be the first button.
public
pay(string $text) : self
Parameters
- $text : string
Return values
selfrow()
Starts a new row. A row that would be left empty is dropped on serialisation.
public
row() : self
Return values
selfswitchInline()
A button that drops the bot's username and a query into a chat the user picks.
public
switchInline(string $text[, string $query = '' ][, bool $currentChat = false ]) : self
Parameters
- $text : string
- $query : string = ''
- $currentChat : bool = false
Return values
selfurl()
A button that opens a URL.
public
url(string $text, string $url) : self
Parameters
- $text : string
- $url : string
Return values
selfwebApp()
A button that launches a Mini App.
public
webApp(string $text, string $url) : self
Parameters
- $text : string
- $url : string