
    IiE                         S r SSKrSSKJrJrJrJrJrJrJ	r	  SSK
Jr  SSKJr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJrJr  SSKJr  \(       a  SSK
Jr   " S S\5      r " S S\5      r " S S\5      r g)z?This module contains an object that represents a Telegram Poll.    N)TYPE_CHECKINGDictFinalListOptionalSequenceTuple)	constants)Chat)MessageEntity)TelegramObject)User)enum)parse_sequence_arg)extract_tzinfo_from_defaultsfrom_timestamp)JSONDict)Botc                      ^  \ rS rSr% SrSrSS.S\S\S\\	   4U 4S	 jjjr
\R                  R                  r\\   \S
'    \R                  R"                  r\\   \S'   SrU =r$ )
PollOption%   a  
This object contains information about one answer option in a poll.

Objects of this class are comparable in terms of equality. Two objects of this class are
considered equal, if their :attr:`text` and :attr:`voter_count` are equal.

Args:
    text (:obj:`str`): Option text,
        :tg-const:`telegram.PollOption.MIN_LENGTH`-:tg-const:`telegram.PollOption.MAX_LENGTH`
        characters.
    voter_count (:obj:`int`): Number of users that voted for this option.

Attributes:
    text (:obj:`str`): Option text,
        :tg-const:`telegram.PollOption.MIN_LENGTH`-:tg-const:`telegram.PollOption.MAX_LENGTH`
        characters.
    voter_count (:obj:`int`): Number of users that voted for this option.

)textvoter_countN
api_kwargsr   r   r   c                   > [         TU ]  US9  Xl        X l        U R                  U R                  4U l        U R                  5         g Nr   )super__init__r   r   	_id_attrs_freeze)selfr   r   r   	__class__s       4/venv/lib/python3.13/site-packages/telegram/_poll.pyr   PollOption.__init__<   s=    J/	 +))T%5%56    
MIN_LENGTH
MAX_LENGTH)r    r   r   )__name__
__module____qualname____firstlineno____doc__	__slots__strintr   r   r   r
   	PollLimitMIN_OPTION_LENGTHr'   r   __annotations__MAX_OPTION_LENGTHr(   __static_attributes____classcell__r#   s   @r$   r   r   %   sx    ( (IX\ S s 8HCU   '00BBJc
B '00BBJc
Br&   r   c                      ^  \ rS rSrSrSr  SSS.S\S\\   S\	\
   S	\	\   S
\	\   4
U 4S jjjjr\S\	\   SSS\	S    4U 4S jj5       rSrU =r$ )
PollAnswerQ   a:  
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 :attr:`poll_id`, :attr:`user` and :attr:`option_ids` are equal.

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

.. versionchanged:: 20.6
   Backward compatiblity for changed order of :paramref:`option_ids` and :paramref:`user`
   was removed.

Args:
    poll_id (:obj:`str`): Unique poll identifier.
    option_ids (Sequence[:obj:`int`]): Identifiers of answer options, chosen by the user. May
        be empty if the user retracted their vote.

        .. versionchanged:: 20.0
            |sequenceclassargs|
    user (:class:`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 :tg-const:`telegram.constants.ChatID.FAKE_CHANNEL` for backwards compatibility.

        .. versionchanged:: 20.5
            :paramref:`user` became optional.
    voter_chat (:class:`telegram.Chat`, optional): The chat that changed the answer to the
        poll, if the voter is anonymous.

        .. versionadded:: 20.5

Attributes:
    poll_id (:obj:`str`): Unique poll identifier.
    option_ids (Tuple[:obj:`int`]): Identifiers of answer options, chosen by the user. May
        be empty if the user retracted their vote.

        .. versionchanged:: 20.0
            |tupleclassattrs|
    user (:class:`telegram.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 :tg-const:`telegram.constants.ChatID.FAKE_CHANNEL` for backwards compatibility

        .. versionchanged:: 20.5
            :paramref:`user` became optional.
    voter_chat (:class:`telegram.Chat`): Optional. The chat that changed the answer to the
        poll, if the voter is anonymous.

        .. versionadded:: 20.5

)
option_idspoll_iduser
voter_chatNr   r<   r;   r=   r>   r   c                   > [         TU ]  US9  Xl        X@l        [	        U5      U l        X0l        U R                  U R
                  U R                  U R                  4U l        U R                  5         g r   )	r   r   r<   r>   r   r;   r=   r    r!   )r"   r<   r;   r=   r>   r   r#   s         r$   r   PollAnswer.__init__   sb     	J/#*4+=j+I$(	 LLOOIIOO	
 	r&   databotr   returnc                    > U R                  U5      nU(       d  g[        R                  " UR                  S5      U5      US'   [        R                  " UR                  S5      U5      US'   [
        TU ]	  XS9$ ),See :meth:`telegram.TelegramObject.de_json`.Nr=   r>   rA   rB   )_parse_datar   de_jsongetr   r   )clsrA   rB   r#   s      r$   rH   PollAnswer.de_json   se     t$||DHHV$4c:V!\\$((<*@#F\wD22r&   )r    r;   r<   r=   r>   )NN)r)   r*   r+   r,   r-   r.   r/   r   r0   r   r   r   r   r   classmethodrH   r5   r6   r7   s   @r$   r9   r9   Q   s    2h @I  $%) *. SM tn	
 TN X& 0 
38H- 
3E 
3h|>T 
3 
3r&   r9   c                      ^  \ rS rSr% SrSr     S+SS.S\S\S\\   S	\	S
\
S\
S\S\
S\\	   S\\   S\\\      S\\	   S\\R                     S\\   4U 4S jjjjr\S\\   SSS\S    4U 4S jj5       rS\S\4S jr S,S\\\      S\\\4   4S jjr\R.                  R0                  r\\   \S'    \R.                  R6                  r\\   \S'    \R8                  R:                  r\\	   \S '    \R8                  R<                  r\\	   \S!'    \R8                  R>                  r\\	   \S"'    \R8                  R@                  r \\	   \S#'    \R8                  RB                  r!\\	   \S$'    \R8                  RD                  r"\\	   \S%'    \R8                  RF                  r#\\	   \S&'    \R8                  RH                  r$\\	   \S''    \R8                  RJ                  r%\\	   \S('    \R8                  RL                  r&\\	   \S)'   S*r'U =r($ )-Poll   a  
This object contains information about a poll.

Objects of this class are comparable in terms of equality. Two objects of this class are
considered equal, if their :attr:`id` is equal.

Examples:
    :any:`Poll Bot <examples.pollbot>`

Args:
    id (:obj:`str`): Unique poll identifier.
    question (:obj:`str`): Poll question, :tg-const:`telegram.Poll.MIN_QUESTION_LENGTH`-
        :tg-const:`telegram.Poll.MAX_QUESTION_LENGTH` characters.
    options (Sequence[:class:`~telegram.PollOption`]): List of poll options.

        .. versionchanged:: 20.0
            |sequenceclassargs|
    is_closed (:obj:`bool`): :obj:`True`, if the poll is closed.
    is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous.
    type (:obj:`str`): Poll type, currently can be :attr:`REGULAR` or :attr:`QUIZ`.
    allows_multiple_answers (:obj:`bool`): :obj:`True`, if the poll allows multiple answers.
    correct_option_id (:obj:`int`, optional): A zero based identifier of the correct answer
        option. Available only for closed polls in the quiz mode, which were sent
        (not forwarded), by the bot or to a private chat with the bot.
    explanation (:obj:`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-:tg-const:`telegram.Poll.MAX_EXPLANATION_LENGTH` characters.
    explanation_entities (Sequence[:class:`telegram.MessageEntity`], optional): Special
        entities like usernames, URLs, bot commands, etc. that appear in the
        :attr:`explanation`. This list is empty if the message does not contain explanation
        entities.

        .. versionchanged:: 20.0

           * This attribute is now always a (possibly empty) list and never :obj:`None`.
           * |sequenceclassargs|
    open_period (:obj:`int`, optional): Amount of time in seconds the poll will be active
        after creation.
    close_date (:obj:`datetime.datetime`, optional): Point in time (Unix timestamp) when the
        poll will be automatically closed. Converted to :obj:`datetime.datetime`.

        .. versionchanged:: 20.3
            |datetime_localization|

Attributes:
    id (:obj:`str`): Unique poll identifier.
    question (:obj:`str`): Poll question, :tg-const:`telegram.Poll.MIN_QUESTION_LENGTH`-
        :tg-const:`telegram.Poll.MAX_QUESTION_LENGTH` characters.
    options (Tuple[:class:`~telegram.PollOption`]): List of poll options.

        .. versionchanged:: 20.0
            |tupleclassattrs|
    total_voter_count (:obj:`int`): Total number of users that voted in the poll.
    is_closed (:obj:`bool`): :obj:`True`, if the poll is closed.
    is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous.
    type (:obj:`str`): Poll type, currently can be :attr:`REGULAR` or :attr:`QUIZ`.
    allows_multiple_answers (:obj:`bool`): :obj:`True`, if the poll allows multiple answers.
    correct_option_id (:obj:`int`): Optional. A zero based identifier of the correct answer
        option. Available only for closed polls in the quiz mode, which were sent
        (not forwarded), by the bot or to a private chat with the bot.
    explanation (:obj:`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-:tg-const:`telegram.Poll.MAX_EXPLANATION_LENGTH` characters.
    explanation_entities (Tuple[:class:`telegram.MessageEntity`]): Special entities
        like usernames, URLs, bot commands, etc. that appear in the :attr:`explanation`.
        This list is empty if the message does not contain explanation entities.

        .. versionchanged:: 20.0
            |tupleclassattrs|

        .. versionchanged:: 20.0
           This attribute is now always a (possibly empty) list and never :obj:`None`.
    open_period (:obj:`int`): Optional. Amount of time in seconds the poll will be active
        after creation.
    close_date (:obj:`datetime.datetime`): Optional. Point in time when the poll will be
        automatically closed.

        .. versionchanged:: 20.3
            |datetime_localization|

)allows_multiple_answers
close_datecorrect_option_idexplanationexplanation_entitiesidis_anonymous	is_closedopen_periodoptionsquestiontotal_voter_counttypeNr   rU   rZ   rY   r[   rW   rV   r\   rP   rR   rS   rT   rX   rQ   r   c                p  > [         TU ]  US9  Xl        X l        [	        U5      U l        X@l        XPl        X`l        [        R                  " [        R                  Xw5      U l        Xl        Xl        Xl        [	        U5      U l        Xl        Xl        U R                  4U l        U R+                  5         g r   )r   r   rU   rZ   r   rY   r[   rW   rV   r   
get_memberr
   PollTyper\   rP   rR   rS   rT   rX   rQ   r    r!   )r"   rU   rZ   rY   r[   rW   rV   r\   rP   rR   rS   rT   rX   rQ   r   r#   s                  r$   r   Poll.__init__  s    $ 	J/%/A'/J&7(".););TH	-D$0A*5?Q @
! +67A''r&   rA   rB   r   rC   c                 R  > U R                  U5      nU(       d  g[        U5      nUS    Vs/ s H  n[        R                  XB5      PM     snUS'   [        R
                  " UR                  S5      U5      US'   [        UR                  S5      US9US'   [        TU ]  XS9$ s  snf )rE   NrY   rT   rQ   )tzinforF   )	rG   r   r   rH   r   de_listrI   r   r   )rJ   rA   rB   
loc_tzinfooptionr#   s        r$   rH   Poll.de_json8  s     t$ 2#6
IMiYv:--f:YY'4'<'<TXXF\=]_b'c#$+DHH\,B:V\wD22	 Zs   B$entityc                     U R                   (       d  [        S5      eU R                   R                  S5      nX!R                  S-  UR                  UR                  -   S-   nUR                  S5      $ )aF  Returns the text from a given :class:`telegram.MessageEntity`.

Note:
    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.text`` with the offset and length.)

Args:
    entity (:class:`telegram.MessageEntity`): The entity to extract the text from. It must
        be an entity that belongs to this message.

Returns:
    :obj:`str`: The text of the given entity.

Raises:
    RuntimeError: If the poll has no explanation.

zThis Poll has no 'explanation'.z	utf-16-le   )rS   RuntimeErrorencodeoffsetlengthdecode)r"   rg   entity_texts      r$   parse_explanation_entityPoll.parse_explanation_entityI  sf    & @AA&&--k:!--!"3v}}v}}7TXY6YZ!!+..r&   typesc                     Uc  [         R                  nU R                   Vs0 s H&  nUR                  U;   d  M  X R	                  U5      _M(     sn$ s  snf )a  
Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`.
It contains entities from this polls explanation filtered by their ``type`` attribute as
the key, and the text that each entity belongs to as the value of the :obj:`dict`.

Note:
    This method should always be used instead of the :attr:`explanation_entities`
    attribute, since it calculates the correct substring from the message text based on
    UTF-16 codepoints. See :attr:`parse_explanation_entity` for more info.

Args:
    types (List[:obj:`str`], optional): List of ``MessageEntity`` types as strings. If the
            ``type`` attribute of an entity is contained in this list, it will be returned.
            Defaults to :attr:`telegram.MessageEntity.ALL_TYPES`.

Returns:
    Dict[:class:`telegram.MessageEntity`, :obj:`str`]: A dictionary of entities mapped to
    the text that belongs to them, calculated based on UTF-16 codepoints.

)r   	ALL_TYPESrT   r\   rp   )r"   rr   rg   s      r$   parse_explanation_entitiesPoll.parse_explanation_entitiesd  s]    . =!++E 33
3{{e# :F11&993
 	
 
s
   AAREGULARQUIZMAX_EXPLANATION_LENGTHMAX_EXPLANATION_LINE_FEEDSMIN_OPEN_PERIODMAX_OPEN_PERIODMIN_QUESTION_LENGTHMAX_QUESTION_LENGTHr2   r4   MIN_OPTION_NUMBERMAX_OPTION_NUMBER)r    rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   )NNNNN)N))r)   r*   r+   r,   r-   r.   r/   r   r   r0   boolr   r   datetimer   r   rL   rH   rp   r   r   ru   r
   r_   rw   r   r3   rx   r1   ry   rz   r{   r|   r}   r~   r2   r4   r   r   r5   r6   r7   s   @r$   rN   rN      s   PdI4 ,0%)BF%)26%  *.!%% % *%	%
 % % % % "&% $C=% c]% 'x'>?% c]% X../%  X&!% %N 38H- 3E 3hv>N 3 3 /} / /8 ,0
d3i(
	mS 	!
@ $,,44GU3Z46 ))..D%*.3)2)<)<)S)SE#JS .7-@-@-[-[c
[ #,"5"5"E"EOU3ZE #,"5"5"E"EOU3ZE '0&9&9&M&MsM '0&9&9&M&MsM %.$7$7$I$IuSzI %.$7$7$I$IuSzI %.$7$7$I$IuSzI %.$7$7$I$IuSzIr&   rN   )!r-   r   typingr   r   r   r   r   r   r	   telegramr
   telegram._chatr   telegram._messageentityr   telegram._telegramobjectr   telegram._userr   telegram._utilsr   telegram._utils.argumentparsingr   telegram._utils.datetimer   r   telegram._utils.typesr   r   r   r9   rN    r&   r$   <module>r      sb   & F  N N N   1 3    > Q *) )XZ3 Z3zK> Kr&   