
    > /iE                         d Z ddlZddlmZmZmZmZmZmZm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZ ddlmZ erddl
mZ  G d de      Z G d de      Z G d de      Z y)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                        e Zd ZU dZdZdddededee   f fdZ	e
j                  j                  Zee   ed	<   	 e
j                  j                   Zee   ed
<    xZS )
PollOptiona  
    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.

    )voter_counttextN
api_kwargsr   r   r   c                    t         |   |       || _        || _        | j                  | j                  f| _        | j                          y Nr   )super__init__r   r   	_id_attrs_freeze)selfr   r   r   	__class__s       D/srv/sistema/bot/venv/lib/python3.12/site-packages/telegram/_poll.pyr   zPollOption.__init__<   sA    J/	 +))T%5%56    
MIN_LENGTH
MAX_LENGTH)__name__
__module____qualname____doc__	__slots__strintr   r   r   r
   	PollLimitMIN_OPTION_LENGTHr%   r   __annotations__MAX_OPTION_LENGTHr&   __classcell__r"   s   @r#   r   r   %   ss    ( (IX\ S s 8HCU  '00BBJc
B '00BBJc
Br$   r   c                        e Zd ZdZdZ	 	 ddddedee   dee	   dee
   d	ee   f
 fd
Zedee   ddded    f fd       Z xZS )
PollAnswera  
    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   r7   r6   r8   r9   r   c                    t         |   |       || _        || _        t	        |      | _        || _        | j                  | j
                  | j                  | j                  f| _        | j                          y r   )	r   r   r7   r9   r   r6   r8   r   r    )r!   r7   r6   r8   r9   r   r"   s         r#   r   zPollAnswer.__init__   sh     	J/#*4+=j+I$(	 LLOOIIOO	
 	r$   databotr   returnc                     | j                  |      }|syt        j                  |j                  d      |      |d<   t	        j                  |j                  d      |      |d<   t
        | 	  ||      S ),See :meth:`telegram.TelegramObject.de_json`.Nr8   r9   r;   r<   )_parse_datar   de_jsongetr   r   )clsr;   r<   r"   s      r#   rB   zPollAnswer.de_json   sg     t$||DHHV$4c:V!\\$((<*@#F\wDc22r$   )NN)r'   r(   r)   r*   r+   r,   r   r-   r   r   r   r   r   classmethodrB   r2   r3   s   @r#   r5   r5   Q   s    2h @I  $%) *. SM tn	
 TN X&0 
38H- 
3E 
3h|>T 
3 
3r$   r5   c                       e Zd ZU dZdZ	 	 	 	 	 d)dddededee   ded	e	d
e	dede	de
e   de
e   de
ee      de
e   de
ej                     de
e   f fdZede
e   ddde
d    f fd       ZdedefdZ	 d*de
ee      deeef   fdZej,                  j.                  Zee   ed<   	 ej,                  j4                  Zee   ed<   	 ej6                  j8                  Zee   ed<   	 ej6                  j:                  Zee   ed <   	 ej6                  j<                  Zee   ed!<   	 ej6                  j>                  Zee   ed"<   	 ej6                  j@                  Z ee   ed#<   	 ej6                  jB                  Z!ee   ed$<   	 ej6                  jD                  Z"ee   ed%<   	 ej6                  jF                  Z#ee   ed&<   	 ej6                  jH                  Z$ee   ed'<   	 ej6                  jJ                  Z%ee   ed(<    xZ&S )+Polla#  
    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|

    )total_voter_countallows_multiple_answersopen_periodoptionstypeexplanation_entitiesis_anonymous
close_date	is_closedidexplanationquestioncorrect_option_idNr   rQ   rS   rK   rH   rP   rN   rL   rI   rT   rR   rM   rJ   rO   r   c                   t         |   |       || _        || _        t	        |      | _        || _        || _        || _        t        j                  t        j                  ||      | _        || _        |	| _        |
| _        t	        |      | _        || _        || _        | j                  f| _        | j+                          y r   )r   r   rQ   rS   r   rK   rH   rP   rN   r   
get_memberr
   PollTyperL   rI   rT   rR   rM   rJ   rO   r   r    )r!   rQ   rS   rK   rH   rP   rN   rL   rI   rT   rR   rM   rJ   rO   r   r"   s                  r#   r   zPoll.__init__  s    $ 	J/%/A'/J&7(".););T4H	-D$0A*5?Q @
! +67A''r$   r;   r<   r   r=   c                 P   | j                  |      }|syt        |      }|d   D cg c]  }t        j                  ||       c}|d<   t	        j
                  |j                  d      |      |d<   t        |j                  d      |      |d<   t        |   ||      S c c}w )r?   NrK   rM   rO   )tzinfor@   )	rA   r   r   rB   r   de_listrC   r   r   )rD   r;   r<   
loc_tzinfooptionr"   s        r#   rB   zPoll.de_json8  s     t$ 2#6
IMiYv:--fc:YY'4'<'<TXXF\=]_b'c#$+DHH\,B:V\wDc22	 Zs   B#entityc                     | j                   st        d      | j                   j                  d      }||j                  dz  |j                  |j                  z   dz   }|j                  d      S )a  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   )rR   RuntimeErrorencodeoffsetlengthdecode)r!   r]   entity_texts      r#   parse_explanation_entityzPoll.parse_explanation_entityI  sh    & @AA&&--k:!&--!"3v}}v}}7TXY6YZ!!+..r$   typesc                     |t         j                  }| j                  D ci c]"  }|j                  |v r|| j	                  |      $ c}S c c}w )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_TYPESrM   rL   rf   )r!   rg   r]   s      r#   parse_explanation_entitieszPoll.parse_explanation_entitiesd  sX    . =!++E 33
{{e# D11&99
 	
 
s   'AREGULARQUIZMAX_EXPLANATION_LENGTHMAX_EXPLANATION_LINE_FEEDSMIN_OPEN_PERIODMAX_OPEN_PERIODMIN_QUESTION_LENGTHMAX_QUESTION_LENGTHr/   r1   MIN_OPTION_NUMBERMAX_OPTION_NUMBER)NNNNN)N)'r'   r(   r)   r*   r+   r,   r   r   r-   boolr   r   datetimer   r   rE   rB   rf   r   r   rj   r
   rW   rk   r   r0   rl   r.   rm   rn   ro   rp   rq   rr   r/   r1   rs   rt   r2   r3   s   @r#   rG   rG      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$   rG   )!r*   rv   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   r5   rG    r$   r#   <module>r      sb   & F  N N N   1 3    > Q *) )XZ3 Z3zK> Kr$   