ReplyKeyboard
in package
implements
JsonSerializable
Builds the `ReplyKeyboardMarkup` that replaces the user's keyboard with buttons of your own.
$telegram->sendMessage($chatId, 'Where are you?', reply_markup: ReplyKeyboard::new()
->requestLocation('Send my location')
->row()
->button('Skip')
->resize()
->oneTime());
remove() and forceReply() cover the other two reply markups, which carry no buttons of their own.
Tags
Table of Contents
Interfaces
- JsonSerializable
Properties
Methods
- add() : self
- Adds a button built by hand.
- button() : self
- A plain button; pressing it sends its text as a message.
- forceReply() : array<string, mixed>
- The `ForceReply` markup, which puts the user straight into a reply.
- jsonSerialize() : array<string, mixed>
- new() : self
- oneTime() : self
- Hides the keyboard once a button has been pressed.
- persistent() : self
- Keeps the keyboard open until it is explicitly replaced or removed.
- placeholder() : self
- The placeholder shown in the input field while the keyboard is up.
- remove() : array<string, mixed>
- The `ReplyKeyboardRemove` markup, which takes a custom keyboard away.
- requestChat() : self
- Asks the user to pick a chat to share with the bot.
- requestContact() : self
- Asks the user to share their phone number. Private chats only.
- requestLocation() : self
- Asks the user to share their location. Private chats only.
- requestPoll() : self
- Asks the user to create a poll. Private chats only.
- requestUsers() : self
- Asks the user to pick users to share with the bot.
- resize() : self
- Shrinks the keyboard to fit its buttons.
- row() : self
- Starts a new row. A row that would be left empty is dropped on serialisation.
- selective() : self
- Shows the keyboard only to the users the message concerns.
- webApp() : self
- Opens a Mini App, whose data comes back as a service message.
Properties
$options
private
array<string, mixed>
$options
= []
$rows
private
array<int, array<int, array<string, mixed>>>
$rows
= [[]]
Methods
add()
Adds a button built by hand.
public
add(array<string, mixed>|string $button) : self
Parameters
- $button : array<string, mixed>|string
-
A
KeyboardButton, or just its text.
Return values
selfbutton()
A plain button; pressing it sends its text as a message.
public
button(string $text) : self
Parameters
- $text : string
Return values
selfforceReply()
The `ForceReply` markup, which puts the user straight into a reply.
public
static forceReply([?string $placeholder = null ][, bool $selective = false ]) : array<string, mixed>
Parameters
- $placeholder : ?string = null
- $selective : bool = false
Return values
array<string, mixed>jsonSerialize()
public
jsonSerialize() : array<string, mixed>
Return values
array<string, mixed>new()
public
static new() : self
Return values
selfoneTime()
Hides the keyboard once a button has been pressed.
public
oneTime([bool $oneTime = true ]) : self
Parameters
- $oneTime : bool = true
Return values
selfpersistent()
Keeps the keyboard open until it is explicitly replaced or removed.
public
persistent([bool $persistent = true ]) : self
Parameters
- $persistent : bool = true
Return values
selfplaceholder()
The placeholder shown in the input field while the keyboard is up.
public
placeholder(string $placeholder) : self
Parameters
- $placeholder : string
Return values
selfremove()
The `ReplyKeyboardRemove` markup, which takes a custom keyboard away.
public
static remove([bool $selective = false ]) : array<string, mixed>
Parameters
- $selective : bool = false
Return values
array<string, mixed>requestChat()
Asks the user to pick a chat to share with the bot.
public
requestChat(string $text, int $requestId[, bool $chatIsChannel = false ][, array<string, mixed> $criteria = [] ]) : self
Parameters
- $text : string
- $requestId : int
- $chatIsChannel : bool = false
- $criteria : array<string, mixed> = []
-
Extra
KeyboardButtonRequestChatfields.
Return values
selfrequestContact()
Asks the user to share their phone number. Private chats only.
public
requestContact(string $text) : self
Parameters
- $text : string
Return values
selfrequestLocation()
Asks the user to share their location. Private chats only.
public
requestLocation(string $text) : self
Parameters
- $text : string
Return values
selfrequestPoll()
Asks the user to create a poll. Private chats only.
public
requestPoll(string $text[, ?string $type = null ]) : self
Parameters
- $text : string
- $type : ?string = null
Return values
selfrequestUsers()
Asks the user to pick users to share with the bot.
public
requestUsers(string $text, int $requestId[, array<string, mixed> $criteria = [] ]) : self
Parameters
- $text : string
- $requestId : int
- $criteria : array<string, mixed> = []
-
Extra
KeyboardButtonRequestUsersfields.
Return values
selfresize()
Shrinks the keyboard to fit its buttons.
public
resize([bool $resize = true ]) : self
Parameters
- $resize : bool = true
Return values
selfrow()
Starts a new row. A row that would be left empty is dropped on serialisation.
public
row() : self
Return values
selfselective()
Shows the keyboard only to the users the message concerns.
public
selective([bool $selective = true ]) : self
Parameters
- $selective : bool = true
Return values
selfwebApp()
Opens a Mini App, whose data comes back as a service message.
public
webApp(string $text, string $url) : self
Parameters
- $text : string
- $url : string