TelegramPHP Documentation

Poll 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 contains information about a poll.

Tags
link
https://core.telegram.org/bots/api#poll
since

v10.3

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

$allows_multiple_answers  : bool
$allows_revoting  : bool
$close_date  : CarbonImmutable|null
$correct_option_ids  : array<int, int>|null
$country_codes  : array<int, string>|null
$description  : string|null
$description_entities  : Collection<string|int, MessageEntity>|null
$explanation  : string|null
$explanation_entities  : Collection<string|int, MessageEntity>|null
$explanation_media  : PollMedia|null
$id  : string
$is_anonymous  : bool
$is_closed  : bool
$media  : PollMedia|null
$members_only  : bool
$open_period  : int|null
$options  : Collection<string|int, PollOption>
$question  : string
$question_entities  : Collection<string|int, MessageEntity>|null
$total_voter_count  : int
$type  : string
$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

$allows_multiple_answers

public bool $allows_multiple_answers

True, if the poll allows multiple answers

$allows_revoting

public bool $allows_revoting

True, if the poll allows to change the chosen answer options

$close_date

public CarbonImmutable|null $close_date

Optional. Point in time (Unix timestamp) when the poll will be automatically closed

$correct_option_ids

public array<int, int>|null $correct_option_ids

Optional. Array of 0-based identifiers of the correct answer options. Available only for polls in quiz mode which are closed or were sent (not forwarded) by the bot or to the private chat with the bot.

$country_codes

public array<int, string>|null $country_codes

Optional. A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which users can vote in the poll. The country code "FT" is used for users with anonymous numbers. If omitted, then users from any country can participate in the poll.

$description

public string|null $description

Optional. Description of the poll; for polls inside the Message object only

$description_entities

public Collection<string|int, MessageEntity>|null $description_entities

Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the description

$explanation

public string|null $explanation

Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters

$explanation_entities

public Collection<string|int, MessageEntity>|null $explanation_entities

Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanation

$explanation_media

public PollMedia|null $explanation_media

Optional. Media added to the quiz explanation

$id

public string $id

Unique poll identifier

$is_anonymous

public bool $is_anonymous

True, if the poll is anonymous

$is_closed

public bool $is_closed

True, if the poll is closed

$media

public PollMedia|null $media

Optional. Media added to the poll description; for polls inside the Message object only

$members_only

public bool $members_only

True if voting is limited to users who have been members of the chat where the poll was originally sent for more than 24 hours

$open_period

public int|null $open_period

Optional. Amount of time in seconds the poll will be active after creation

$options

public Collection<string|int, PollOption> $options

List of poll options

$question

public string $question

Poll question, 1-300 characters

$question_entities

public Collection<string|int, MessageEntity>|null $question_entities

Optional. Special entities that appear in the question. Currently, only custom emoji entities are allowed in poll questions

$total_voter_count

public int $total_voter_count

Total number of users that voted in the poll

$type

public string $type

Poll type, currently can be "regular" or "quiz"

$casts

Attribute name => Telegram type token ("User", "Array of PhotoSize"), used to hydrate nested objects into parts.

protected array<string, string> $casts = ['question_entities' => 'Array of MessageEntity', 'options' => 'Array of PollOption', 'country_codes' => 'Array of String', 'correct_option_ids' => 'Array of Integer', 'explanation_entities' => 'Array of MessageEntity', 'explanation_media' => 'PollMedia', 'description_entities' => 'Array of MessageEntity', 'media' => 'PollMedia']

$dates

Attribute names holding Unix timestamps, read back as {@see CarbonImmutable}.

protected array<int, string> $dates = ['close_date']

$fillable

Attribute names this part accepts. Empty = accept anything.

protected array<int, string> $fillable = ['id', 'question', 'question_entities', 'options', 'total_voter_count', 'is_closed', 'is_anonymous', 'type', 'allows_multiple_answers', 'allows_revoting', 'members_only', 'country_codes', 'correct_option_ids', 'explanation', 'explanation_entities', 'explanation_media', 'open_period', 'close_date', 'description', 'description_entities', 'media']

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
string

attributeExists()

public attributeExists(string $key) : bool
Parameters
$key : string
Return values
bool

fill()

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>

jsonSerialize()

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
bool

offsetGet()

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
throws
PartException

When the part is not a union, or nothing matches.

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
Factory

getRawAttribute()

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
On this page

Search results