Poll(id, question, options, total_voter_count, is_closed, is_anonymous, type, allows_multiple_answers, correct_option_id=None, explanation=None, explanation_entities=None, open_period=None, close_date=None, **kwargs)¶
This object contains information about a poll.
Unique poll identifier.
Poll question, 1-255 characters.
Total number of users that voted in the poll.
True, if the poll is closed.
True, if the poll is anonymous.
True, if the poll allows multiple answers.
Optional. Identifier of the correct answer option.
Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll.
Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the
Optional. Amount of time in seconds the poll will be active after creation.
Optional. Point in time when the poll will be automatically closed.
- id (
str) – Unique poll identifier.
- question (
str) – Poll question, 1-255 characters.
- options (List[
PollOption]) – List of poll options.
- is_closed (
bool) – True, if the poll is closed.
- is_anonymous (
bool) – True, if the poll is anonymous.
- type (
str) – Poll type, currently can be
- allows_multiple_answers (
bool) – True, if the poll allows multiple answers.
- correct_option_id (
int, optional) – 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot.
- explanation (
str, 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 (List[
telegram.MessageEntity], optional) – Special entities like usernames, URLs, bot commands, etc. that appear in the
- open_period (
int, optional) – Amount of time in seconds the poll will be active after creation.
- close_date (
datetime.datetime, optional) – Point in time (Unix timestamp) when the poll will be automatically closed. Converted to
str. It contains entities from this polls explanation filtered by their
typeattribute as the key, and the text that each entity belongs to as the value of the
This method should always be used instead of the
explanation_entitiesattribute, since it calculates the correct substring from the message text based on UTF-16 codepoints. See
parse_explanation_entityfor more info.
Parameters: types (List[
str], optional) – List of
MessageEntitytypes as strings. If the
typeattribute of an entity is contained in this list, it will be returned. Defaults to
Returns: A dictionary of entities mapped to the text that belongs to them, calculated based on UTF-16 codepoints. Return type: Dict[
Returns the text from a given
This method is present because Telegram calculates the offset and length in UTF-16 codepoint pairs, which some versions of Python don’t handle automatically. (That is, you can’t just slice
Message.textwith the offset and length.)
Parameters: entity (
telegram.MessageEntity) – The entity to extract the text from. It must be an entity that belongs to this message.
Returns: The text of the given entity. Return type: