KeyboardButton
extends Part
in package
This file is generated from spec/openapi.json (Bot API 10.3) by tools/generate.php.
Do not edit it by hand - run composer spec:build instead.
This object represents one button of the reply keyboard. At most one of the fields other than text, icon_custom_emoji_id, and style must be used to specify the type of the button. For simple text buttons, String can be used instead of this object to specify the button text.
Tags
Table of Contents
Constants
- DISCRIMINATOR : mixed = null
- The attribute whose value names the concrete subtype, for union parents.
- SUBTYPES : array<string, Part>>|array<int, Part>> = []
- The concrete classes a union parent may resolve to - keyed by discriminator value when there is one, a plain list otherwise. Empty on ordinary parts.
Properties
- $icon_custom_emoji_id : string|null
- $request_chat : KeyboardButtonRequestChat|null
- $request_contact : bool|null
- $request_location : bool|null
- $request_managed_bot : KeyboardButtonRequestManagedBot|null
- $request_poll : KeyboardButtonPollType|null
- $request_users : KeyboardButtonRequestUsers|null
- $style : string|null
- $text : string
- $web_app : WebAppInfo|null
- $casts : array<string, string>
- Attribute name => Telegram type token ("User", "Array of PhotoSize"), used to hydrate nested objects into parts.
- $dates : array<int, string>
- Attribute names holding Unix timestamps, read back as {@see CarbonImmutable}.
- $fillable : array<int, string>
- Attribute names this part accepts. Empty = accept anything.
- $telegram : Telegram
Methods
- __construct() : mixed
- __debugInfo() : array<string, mixed>
- __get() : mixed
- __isset() : bool
- __set() : void
- __toString() : string
- attributeExists() : bool
- fill() : void
- getAttribute() : mixed
- getCasts() : array<string, string>
- getFillable() : array<int, string>
- getRawAttributes() : array<string, mixed>
- getTelegram() : Telegram
- jsonSerialize() : array<string, mixed>
- The payload this part would be sent back to Telegram as - nested parts and collections flattened, timestamps left as the integers they arrived as.
- offsetExists() : bool
- offsetGet() : mixed
- offsetSet() : void
- offsetUnset() : void
- resolveSubtype() : Part>
- The concrete class an incoming payload belongs to, for a union parent.
- setAttribute() : void
- factory() : Factory
- Builds another part from the same client - for nested objects.
- getRawAttribute() : mixed
- Reads straight from the attribute bag, skipping the `get{Key}Attribute` hook.
- setRawAttribute() : void
- Writes straight to the attribute bag, skipping the `set{Key}Attribute` hook and any cast. For use *inside* a mutator, which would otherwise have no way to store its shaped value without recursing through {@see setAttribute()}.
Constants
DISCRIMINATOR
The attribute whose value names the concrete subtype, for union parents.
public
mixed
DISCRIMINATOR
= null
null on ordinary parts and on unions Telegram does not tag.
SUBTYPES
The concrete classes a union parent may resolve to - keyed by discriminator value when there is one, a plain list otherwise. Empty on ordinary parts.
public
array<string, Part>>|array<int, Part>>
SUBTYPES
= []
Properties
$icon_custom_emoji_id
public
string|null
$icon_custom_emoji_id
Optional. Unique identifier of the custom emoji shown before the text of the button. Can only be used by bots that purchased additional usernames on Fragment or in the messages directly sent by the bot to private, group and supergroup chats if the owner of the bot has a Telegram Premium subscription.
$request_chat
public
KeyboardButtonRequestChat|null
$request_chat
Optional. If specified, pressing the button will open a list of suitable chats. Tapping on a chat will send its identifier to the bot in a "chat_shared" service message. Available in private chats only.
$request_contact
public
bool|null
$request_contact
Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only.
$request_location
public
bool|null
$request_location
Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only.
$request_managed_bot
public
KeyboardButtonRequestManagedBot|null
$request_managed_bot
Optional. If specified, pressing the button will ask the user to create and share a bot that will be managed by the current bot. Available for bots that enabled management of other bots in the @BotFather Mini App. Available in private chats only.
$request_poll
public
KeyboardButtonPollType|null
$request_poll
Optional. If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only.
$request_users
public
KeyboardButtonRequestUsers|null
$request_users
Optional. If specified, pressing the button will open a list of suitable users. Identifiers of selected users will be sent to the bot in a "users_shared" service message. Available in private chats only.
$style
public
string|null
$style
Optional. Style of the button. Must be one of "danger" (red), "success" (green) or "primary" (blue). If omitted, then an app-specific style is used.
$text
public
string
$text
Text of the button. If none of the fields other than text, icon_custom_emoji_id, and style are used, it will be sent as a message when the button is pressed.
$web_app
public
WebAppInfo|null
$web_app
Optional. If specified, the described Web App will be launched when the button is pressed. The Web App will be able to send a "web_app_data" service message. Available in private chats only.
$casts
Attribute name => Telegram type token ("User", "Array of PhotoSize"), used to hydrate nested objects into parts.
protected
array<string, string>
$casts
= ['request_users' => 'KeyboardButtonRequestUsers', 'request_chat' => 'KeyboardButtonRequestChat', 'request_managed_bot' => 'KeyboardButtonRequestManagedBot', 'request_poll' => 'KeyboardButtonPollType', 'web_app' => 'WebAppInfo']
$dates
Attribute names holding Unix timestamps, read back as {@see CarbonImmutable}.
protected
array<int, string>
$dates
= []
$fillable
Attribute names this part accepts. Empty = accept anything.
protected
array<int, string>
$fillable
= ['text', 'icon_custom_emoji_id', 'style', 'request_users', 'request_chat', 'request_managed_bot', 'request_contact', 'request_location', 'request_poll', 'web_app']
$telegram read-only
protected
Telegram
$telegram
Methods
__construct()
public
__construct(Telegram $telegram[, array<string, mixed>|object $attributes = [] ]) : mixed
Parameters
- $telegram : Telegram
- $attributes : array<string, mixed>|object = []
__debugInfo()
public
__debugInfo() : array<string, mixed>
Return values
array<string, mixed>__get()
public
__get(string $name) : mixed
Parameters
- $name : string
__isset()
public
__isset(string $name) : bool
Parameters
- $name : string
Return values
bool__set()
public
__set(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
__toString()
public
__toString() : string
Return values
stringattributeExists()
public
attributeExists(string $key) : bool
Parameters
- $key : string
Return values
boolfill()
public
fill(array<string, mixed> $attributes) : void
Parameters
- $attributes : array<string, mixed>
getAttribute()
public
getAttribute(string $key) : mixed
Parameters
- $key : string
getCasts()
public
getCasts() : array<string, string>
Return values
array<string, string>getFillable()
public
getFillable() : array<int, string>
Return values
array<int, string>getRawAttributes()
public
getRawAttributes() : array<string, mixed>
Return values
array<string, mixed>getTelegram()
public
getTelegram() : Telegram
Return values
TelegramjsonSerialize()
The payload this part would be sent back to Telegram as - nested parts and collections flattened, timestamps left as the integers they arrived as.
public
jsonSerialize() : array<string, mixed>
Return values
array<string, mixed>offsetExists()
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
booloffsetGet()
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
offsetSet()
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
offsetUnset()
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
resolveSubtype()
The concrete class an incoming payload belongs to, for a union parent.
public
static resolveSubtype(array<string, mixed> $attributes) : Part>
Tagged unions resolve on their discriminator. The handful Telegram leaves
untagged (InputMessageContent, and the rest), and any payload whose tag
this build does not recognise - a member added to the Bot API since it was
generated - resolve instead to the subtype whose attributes the payload
matches most closely.
Parameters
- $attributes : array<string, mixed>
Tags
Return values
Part>setAttribute()
public
setAttribute(string $key, mixed $value) : void
Parameters
- $key : string
- $value : mixed
factory()
Builds another part from the same client - for nested objects.
protected
factory() : Factory
Return values
FactorygetRawAttribute()
Reads straight from the attribute bag, skipping the `get{Key}Attribute` hook.
protected
getRawAttribute(string $key) : mixed
Parameters
- $key : string
setRawAttribute()
Writes straight to the attribute bag, skipping the `set{Key}Attribute` hook and any cast. For use *inside* a mutator, which would otherwise have no way to store its shaped value without recursing through {@see setAttribute()}.
protected
setRawAttribute(string $key, mixed $value) : void
Parameters
- $key : string
- $value : mixed