Hide navigation sidebar
Hide table of contents sidebar
PTB has undergone significant changes in v20. Please read the documentation carefully and also check out the transition guide in the wiki.
Back to top
Toggle table of contents sidebar

# PollAnswer

class telegram.PollAnswer(poll_id, option_ids, user=None, voter_chat=None, *, api_kwargs=None)

  Bases: `telegram.TelegramObject`

  This object represents an answer of a user in a non-anonymous poll.

  Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their `poll_id`, `user` and `option_ids` are equal.

  Available In

  `telegram.Update.poll_answer`

  Changed in version 20.5: The order of `option_ids` and `user` is changed in 20.5 as the latter one became optional.

  Changed in version 20.6: Backward compatiblity for changed order of `option_ids` and `user` was removed.

  Parameters:

    - poll_id (`str`) – Unique poll identifier.

    - option_ids (Sequence[`int`]) –

      Identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.

      Changed in version 20.0: Accepts any `collections.abc.Sequence` as input instead of just a list. The input is converted to a tuple.

    - user (`telegram.User`, optional) –

      The user that changed the answer to the poll, if the voter isn’t anonymous. If the voter is anonymous, this field will contain the user `136817688` for backwards compatibility.

      Changed in version 20.5: `user` became optional.

    - voter_chat (`telegram.Chat`, optional) –

      The chat that changed the answer to the poll, if the voter is anonymous.

      New in version 20.5.

  poll_id

    Unique poll identifier.

    Type:

      `str`

  option_ids

    Identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.

    Changed in version 20.0: This attribute is now an immutable tuple.

    Type:

      Tuple[`int`]

  user

    Optional. The user, who changed the answer to the poll, if the voter isn’t anonymous. If the voter is anonymous, this field will contain the user `136817688` for backwards compatibility

    Changed in version 20.5: `user` became optional.

    Type:

      `telegram.User`

  voter_chat

    Optional. The chat that changed the answer to the poll, if the voter is anonymous.

    New in version 20.5.

    Type:

      `telegram.Chat`

  classmethod de_json(data, bot)

    See `telegram.TelegramObject.de_json()`.