
    YiJi                     2   S r SSKrSSKJr  SSK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  SSKJrJr  SSKJrJ r   \(       a  SSKJ!r!   " S S\5      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)Sequence)TYPE_CHECKINGFinalOptional)	constants)Chat)MessageEntity)TelegramObject)User)enum)parse_sequence_arg)extract_tzinfo_from_defaultsfrom_timestamp)DEFAULT_NONE)parse_message_entitiesparse_message_entity)JSONDictODVInput)Botc                      ^  \ rS rSrSrSr\S4SS.S\S\\   S\	\
\      S	\	\   4U 4S
 jjjjr\ SS\	\   S\	S   S\	S    4U 4S jjj5       rSrU =r$ )InputPollOption(   a  
This object contains information about one answer option in a poll to be sent.

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

.. versionadded:: 21.2

Args:
    text (:obj:`str`): Option text,
        :tg-const:`telegram.PollOption.MIN_LENGTH`-:tg-const:`telegram.PollOption.MAX_LENGTH`
        characters.
    text_parse_mode (:obj:`str`, optional): |parse_mode|
        Currently, only custom emoji entities are allowed.
    text_entities (Sequence[:class:`telegram.MessageEntity`], optional): Special entities
        that appear in the option :paramref:`text`. It can be specified instead of
        :paramref:`text_parse_mode`.
        Currently, only custom emoji entities are allowed.
        This list is empty if the text does not contain entities.

Attributes:
    text (:obj:`str`): Option text,
        :tg-const:`telegram.PollOption.MIN_LENGTH`-:tg-const:`telegram.PollOption.MAX_LENGTH`
        characters.
    text_parse_mode (:obj:`str`): Optional. |parse_mode|
        Currently, only custom emoji entities are allowed.
    text_entities (Sequence[:class:`telegram.MessageEntity`]): Special entities
        that appear in the option :paramref:`text`. It can be specified instead of
        :paramref:`text_parse_mode`.
        Currently, only custom emoji entities are allowed.
        This list is empty if the text does not contain entities.
)texttext_entitiestext_parse_modeN
api_kwargsr   r   r   r   c                   > [         TU ]  US9  Xl        X l        [	        U5      U l        U R                  4U l        U R                  5         g Nr   )super__init__r   r   r   r   	_id_attrs_freeze)selfr   r   r   r   	__class__s        9/app/.venv/lib/python3.13/site-packages/telegram/_poll.pyr!   InputPollOption.__init__L   sC     	J/	.=8J=8Y))    databotr   returnc                    > U R                  U5      nU(       d  g[        R                  " UR                  S5      U5      US'   [        TU ]  XS9$ ,See :meth:`telegram.TelegramObject.de_json`.Nr   r)   r*   _parse_datar	   de_listgetr    de_jsonclsr)   r*   r%   s      r&   r4   InputPollOption.de_json]   K    
 t$ - 5 5dhh6OQT U_wD22r(   )r"   r   r   r   N)__name__
__module____qualname____firstlineno____doc__	__slots__r   strr   r   r   r	   r   r!   classmethodr4   __static_attributes____classcell__r%   s   @r&   r   r   (   s    B =I
 *6;?	 *. "#   78	 X& " >B3H%3,4UO3	#	$3 3r(   r   c                   \  ^  \ rS rSr% SrSr SSS.S\S\S\\	\
      S	\\   4U 4S
 jjjjr\ SS\\   S\S   S\S    4U 4S jjj5       rS\
S\4S jrSS\\\      S\\
\4   4S jjr\R(                  R*                  r\\   \S'    \R(                  R2                  r\\   \S'   SrU =r$ )
PollOptionl   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.
    text_entities (Sequence[:class:`telegram.MessageEntity`], optional): Special entities
        that appear in the option text. Currently, only custom emoji entities are allowed in
        poll option texts.

        .. versionadded:: 21.2

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_entities (tuple[:class:`telegram.MessageEntity`]): Special entities
        that appear in the option text. Currently, only custom emoji entities are allowed in
        poll option texts.
        This list is empty if the question does not contain entities.

        .. versionadded:: 21.2

)r   r   voter_countNr   r   rH   r   r   c                   > [         TU ]  US9  Xl        X l        [	        U5      U l        U R                  U R                  4U l        U R                  5         g r   )r    r!   r   rH   r   r   r"   r#   )r$   r   rH   r   r   r%   s        r&   r!   PollOption.__init__   sL     	J/	 +8J=8Y))T%5%56r(   r)   r*   r   r+   c                    > U R                  U5      nU(       d  g[        R                  " UR                  S5      U5      US'   [        TU ]  XS9$ r-   r0   r5   s      r&   r4   PollOption.de_json   r8   r(   entityc                 .    [        U R                  U5      $ )aT  Returns the text in :attr:`text`
from a given :class:`telegram.MessageEntity` of :attr:`text_entities`.

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.)

.. versionadded:: 21.2

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

Returns:
    :obj:`str`: The text of the given entity.
)r   r   r$   rM   s     r&   parse_entityPollOption.parse_entity   s    $ $DIIv66r(   typesc                 D    [        U R                  U R                  U5      $ )a  
Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`.
It contains entities from this polls question 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:`text_entities`
    attribute, since it calculates the correct substring from the message text based on
    UTF-16 codepoints. See :attr:`parse_entity` for more info.

.. versionadded:: 21.2

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   r   r   r$   rR   s     r&   parse_entitiesPollOption.parse_entities   s    , &dii1C1CUKKr(   
MIN_LENGTH
MAX_LENGTH)r"   r   r   rH   r9   )r:   r;   r<   r=   r>   r?   r@   intr   r   r	   r   r!   rA   r4   rP   listdictrU   r   	PollLimitMIN_OPTION_LENGTHrW   r   __annotations__MAX_OPTION_LENGTHrX   rB   rC   rD   s   @r&   rF   rF   l   s   > 9I <@	 *.    78	 X& " >B3H%3,4UO3	,	3 37= 7S 7(LHT#Y$7 L4WZHZC[ L0 '00BBJc
B '00BBJc
Br(   rF   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\	S    4U 4S jjj5       rSrU =r$ )
PollAnswer   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   rd   rc   re   rf   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!   rd   rf   r   rc   re   r"   r#   )r$   rd   rc   re   rf   r   r%   s         r&   r!   PollAnswer.__init__  sb     	J/#*4+=j+I$(	 LLOOIIOO	
 	r(   r)   r*   r   r+   c                    > 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$ )r.   Nre   rf   r/   )r1   r   r4   r3   r   r    r5   s      r&   r4   PollAnswer.de_json4  se    
 t$||DHHV$4c:V!\\$((<*@#F\wD22r(   )r"   rc   rd   re   rf   )NNr9   )r:   r;   r<   r=   r>   r?   r@   r   rY   r   r   r   r   r!   rA   r4   rB   rC   rD   s   @r&   ra   ra      s    2h @I  $%) *. SM tn	
 TN X& 0 >B3H%3,4UO3	,	3 3r(   ra   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\\\      S\\   4U 4S jjjjr\S/S\\   S\S   S\S    4U 4S jjj5       rS\S\4S jr S/S\\\      S\\\4   4S jjrS\S\4S jr S/S\\\      S\\\4   4S  jjr\R2                  R4                  r\\   \S!'    \R2                  R:                  r\\   \S"'    \R<                  R>                  r\\	   \S#'    \R<                  R@                  r \\	   \S$'    \R<                  RB                  r!\\	   \S%'    \R<                  RD                  r"\\	   \S&'    \R<                  RF                  r#\\	   \S''    \R<                  RH                  r$\\	   \S('    \R<                  RJ                  r%\\	   \S)'    \R<                  RL                  r&\\	   \S*'    \R<                  RN                  r'\\	   \S+'    \R<                  RP                  r(\\	   \S,'   S-r)U =r*$ )0PolliD  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|
    question_entities (Sequence[:class:`telegram.MessageEntity`], optional): Special entities
        that appear in the :attr:`question`. Currently, only custom emoji entities are allowed
        in poll questions.

        .. versionadded:: 21.2

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|
    question_entities (tuple[:class:`telegram.MessageEntity`]): Special entities
        that appear in the :attr:`question`. Currently, only custom emoji entities are allowed
        in poll questions.
        This list is empty if the question does not contain entities.

        .. versionadded:: 21.2

)allows_multiple_answers
close_datecorrect_option_idexplanationexplanation_entitiesidis_anonymous	is_closedopen_periodoptionsquestionquestion_entitiestotal_voter_counttypeNr   rr   rw   rv   ry   rt   rs   rz   rm   ro   rp   rq   ru   rn   rx   r   c                  > [         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5      U l        U R                  4U l        U R-                  5         g r   )r    r!   rr   rw   r   rv   ry   rt   rs   r   
get_memberr   PollTyperz   rm   ro   rp   rq   ru   rn   rx   r"   r#   )r$   rr   rw   rv   ry   rt   rs   rz   rm   ro   rp   rq   ru   rn   rx   r   r%   s                   r&   r!   Poll.__init__  s    & 	J/%/A'/J&7(".););TH	-D$0A*5?Q @
! +67A<NO`<a''r(   r)   r*   r   r+   c                   > 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'   [        R
                  " UR                  S5      U5      US'   [        TU ]  XS9$ s  snf )r.   Nrv   rq   rn   )tzinforx   r/   )	r1   r   rF   r4   r	   r2   r3   r   r    )r6   r)   r*   
loc_tzinfooptionr%   s        r&   r4   Poll.de_json  s     t$ 2#6
IMiYv:--f:YY'4'<'<TXXF\=]_b'c#$+DHH\,B:V\$1$9$9$((CV:WY\$] !wD22 Zs   CrM   c                 f    U R                   (       d  [        S5      e[        U R                   U5      $ )a  Returns the text in :attr:`explanation` from a given :class:`telegram.MessageEntity` of
:attr:`explanation_entities`.

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 :attr:`explanation_entities`.

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

Raises:
    RuntimeError: If the poll has no explanation.

This Poll has no 'explanation'.)rp   RuntimeErrorr   rO   s     r&   parse_explanation_entityPoll.parse_explanation_entity  s,    ( @AA#D$4$4f==r(   rR   c                 |    U R                   (       d  [        S5      e[        U R                   U R                  U5      $ )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.

Raises:
    RuntimeError: If the poll has no explanation.

r   )rp   r   r   rq   rT   s     r&   parse_explanation_entitiesPoll.parse_explanation_entities  s5    4 @AA%d&6&68Q8QSXYYr(   c                 .    [        U R                  U5      $ )a`  Returns the text in :attr:`question` from a given :class:`telegram.MessageEntity` of
:attr:`question_entities`.

.. versionadded:: 21.2

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 :attr:`question_entities`.

Returns:
    :obj:`str`: The text of the given entity.
)r   rw   rO   s     r&   parse_question_entityPoll.parse_question_entity&  s    $ $DMM6::r(   c                 D    [        U R                  U R                  U5      $ )a  
Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`.
It contains entities from this polls question filtered by their ``type`` attribute as
the key, and the text that each entity belongs to as the value of the :obj:`dict`.

.. versionadded:: 21.2

Note:
    This method should always be used instead of the :attr:`question_entities`
    attribute, since it calculates the correct substring from the message text based on
    UTF-16 codepoints. See :attr:`parse_question_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   rw   rx   rT   s     r&   parse_question_entitiesPoll.parse_question_entities:  s    2 &dmmT5K5KUSSr(   REGULARQUIZMAX_EXPLANATION_LENGTHMAX_EXPLANATION_LINE_FEEDSMIN_OPEN_PERIODMAX_OPEN_PERIODMIN_QUESTION_LENGTHMAX_QUESTION_LENGTHr]   r_   MIN_OPTION_NUMBERMAX_OPTION_NUMBER)r"   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   )NNNNNNr9   )+r:   r;   r<   r=   r>   r?   r@   r   rF   rY   boolr   r	   datetimer   r!   rA   r4   r   rZ   r[   r   r   r   r   r}   r   r   r^   r   r\   r   r   r   r   r   r   r]   r_   r   r   rB   rC   rD   s   @r&   rl   rl   D  sM   [zI6 ,0%)BF%)26?C'" *.#'' ' *%	'
 ' ' ' ' "&' $C=' c]' 'x'>?' c]' X../' $H]$;<'" X&#' 'R 38H- 3HUO 3xX^O_ 3 3">} > >4 ,0Zd3i(Z	mS 	!Z>;M ;c ;* ,0Td3i(T	mS 	!T6 $,,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(   rl   )&r>   r   collections.abcr   typingr   r   r   telegramr   telegram._chatr   telegram._messageentityr	   telegram._telegramobjectr
   telegram._userr   telegram._utilsr   telegram._utils.argumentparsingr   telegram._utils.datetimer   r   telegram._utils.defaultvaluer   telegram._utils.entitiesr   r   telegram._utils.typesr   r   r   r   rF   ra   rl    r(   r&   <module>r      sy   & F  $ 1 1   1 3    > Q 5 Q 4A3n A3Hv vr\3 \3~F> Fr(   