
    YPi9                         d Z ddlmZ ddl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mZ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 G d de      Zy)z:This module contains classes related to gifs sent by bots.    )Sequence)TYPE_CHECKINGOptional)Chat)Sticker)MessageEntity)TelegramObject)de_json_optionalde_list_optionalparse_sequence_arg)parse_message_entitiesparse_message_entity)JSONDict)Botc                        e Zd ZdZdZ	 	 	 	 ddddedededee   d	ee   d
ee   dee	   dee
   f fdZedde
ded   dd f fd       Z xZS )Gifta  This object represents a gift that can be sent by the bot.

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

    .. versionadded:: 21.8

    Args:
        id (:obj:`str`): Unique identifier of the gift.
        sticker (:class:`~telegram.Sticker`): The sticker that represents the gift.
        star_count (:obj:`int`): The number of Telegram Stars that must be paid to send the
            sticker.
        total_count (:obj:`int`, optional): The total number of the gifts of this type that can be
            sent; for limited gifts only.
        remaining_count (:obj:`int`, optional): The number of remaining gifts of this type that can
            be sent; for limited gifts only.
        upgrade_star_count (:obj:`int`, optional): The number of Telegram Stars that must be paid
            to upgrade the gift to a unique one.

            .. versionadded:: 21.10
        publisher_chat (:class:`telegram.Chat`, optional): Information about the chat that
            published the gift.

            .. versionadded:: 22.4

    Attributes:
        id (:obj:`str`): Unique identifier of the gift.
        sticker (:class:`~telegram.Sticker`): The sticker that represents the gift.
        star_count (:obj:`int`): The number of Telegram Stars that must be paid to send the
            sticker.
        total_count (:obj:`int`): Optional. The total number of the gifts of this type that can be
            sent; for limited gifts only.
        remaining_count (:obj:`int`): Optional. The number of remaining gifts of this type that can
            be sent; for limited gifts only.
        upgrade_star_count (:obj:`int`): Optional. The number of Telegram Stars that must be paid
            to upgrade the gift to a unique one.

            .. versionadded:: 21.10
        publisher_chat (:class:`telegram.Chat`): Optional. Information about the chat that
            published the gift.

            .. versionadded:: 22.4

    )idpublisher_chatremaining_count
star_countstickertotal_countupgrade_star_countN
api_kwargsr   r   r   r   r   r   r   r   c                    t         	|   |       || _        || _        || _        || _        || _        || _        || _        | j                  f| _	        | j                          y Nr   )super__init__r   r   r   r   r   r   r   	_id_attrs_freeze)
selfr   r   r   r   r   r   r   r   	__class__s
            E/root/twitch_bot/venv/lib/python3.12/site-packages/telegram/_gifts.pyr   zGift.__init__]   s`     	J/ ')*5.=1C.<''    databotr   returnc                     | j                  |      }t        |j                  d      t        |      |d<   t        |j                  d      t        |      |d<   t
        |   ||      S ),See :meth:`telegram.TelegramObject.de_json`.r   r   r&   r'   )_parse_datar
   getr   r   r   de_jsonclsr&   r'   r#   s      r$   r.   zGift.de_jsonv   s`     t$*488I+>MY!1$((;K2LdTW!XwDc22r%   )NNNNN)__name__
__module____qualname____doc__	__slots__strr   intr   r   r   r   classmethodr.   __classcell__r#   s   @r$   r   r   %   s    +ZI &*)-,0)- *.  	
 c] "# %SM ! X&2 38 3(5/ 3V 3 3r%   r   c                   l     e Zd ZdZdZdddee   dee   f fdZ	e
dded	ed
   dd f fd       Z xZS )Giftsav  This object represent a list of gifts.

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

    .. versionadded:: 21.8

    Args:
        gifts (Sequence[:class:`Gift`]): The sequence of gifts.

    Attributes:
        gifts (tuple[:class:`Gift`]): The sequence of gifts.

    )giftsNr   r>   r   c                    t         |   |       t        |      | _        | j                  f| _        | j                          y r   )r   r   r   r>   r    r!   )r"   r>   r   r#   s      r$   r   zGifts.__init__   s7     	J/'9%'@
**r%   r&   r'   r   r(   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )r*   r>   r+   )r,   r   r-   r   r   r.   r/   s      r$   r.   zGifts.de_json   sA     t$('):D#FWwDc22r%   r1   )r2   r3   r4   r5   r6   r   r   r   r   r   r9   r.   r:   r;   s   @r$   r=   r=      sa     I *.	~ X&	 38 3(5/ 3W 3 3r%   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	   d
ee   dee
e      dee	   dee   f fdZeddeded   d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 xZS )GiftInfoa	  Describes a service message about a regular gift that was sent or received.

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

    .. versionadded:: 22.1

    Args:
        gift (:class:`Gift`): Information about the gift.
        owned_gift_id (:obj:`str`, optional): Unique identifier of the received gift for the bot;
            only present for gifts received on behalf of business accounts.
        convert_star_count (:obj:`int`, optional) Number of Telegram Stars that can be claimed by
            the receiver by converting the gift; omitted if conversion to Telegram Stars
            is impossible.
        prepaid_upgrade_star_count (:obj:`int`, optional): Number of Telegram Stars that were
            prepaid by the sender for the ability to upgrade the gift.
        can_be_upgraded (:obj:`bool`, optional): :obj:`True`, if the gift can be upgraded
            to a unique gift.
        text (:obj:`str`, optional): Text of the message that was added to the gift.
        entities (Sequence[:class:`telegram.MessageEntity`], optional): Special entities that
            appear in the text.
        is_private (:obj:`bool`, optional): :obj:`True`, if the sender and gift text are
            shown only to the gift receiver; otherwise, everyone will be able to see them.

    Attributes:
        gift (:class:`Gift`): Information about the gift.
        owned_gift_id (:obj:`str`): Optional. Unique identifier of the received gift for the bot;
            only present for gifts received on behalf of business accounts.
        convert_star_count (:obj:`int`): Optional. Number of Telegram Stars that can be claimed by
            the receiver by converting the gift; omitted if conversion to Telegram Stars
            is impossible.
        prepaid_upgrade_star_count (:obj:`int`): Optional. Number of Telegram Stars that were
            prepaid by the sender for the ability to upgrade the gift.
        can_be_upgraded (:obj:`bool`): Optional. :obj:`True`, if the gift can be upgraded
            to a unique gift.
        text (:obj:`str`): Optional. Text of the message that was added to the gift.
        entities (Sequence[:class:`telegram.MessageEntity`]): Optional. Special entities that
            appear in the text.
        is_private (:obj:`bool`): Optional. :obj:`True`, if the sender and gift text are
            shown only to the gift receiver; otherwise, everyone will be able to see them.

    )can_be_upgradedconvert_star_countentitiesgift
is_privateowned_gift_idprepaid_upgrade_star_counttextNr   rF   rH   rD   rI   rC   rJ   rE   rG   r   c	                    t         
|   |	       || _        || _        || _        || _        || _        || _        t        |      | _	        || _
        | j                  f| _        | j                          y r   )r   r   rF   rH   rD   rI   rC   rJ   r   rE   rG   r    r!   )r"   rF   rH   rD   rI   rC   rJ   rE   rG   r   r#   s             r$   r   zGiftInfo.__init__   sl     	J/	,91C9S'/>#'	3Eh3O*4))r%   r&   r'   r   r(   c                     | j                  |      }t        |j                  d      t        |      |d<   t	        |j                  d      t
        |      |d<   t        |   ||      S )r*   rF   rE   r+   )r,   r
   r-   r   r   r   r   r.   r/   s      r$   r.   zGiftInfo.de_json   s^     t$'(8$DV+DHHZ,@-QTUZwDc22r%   entityc                 \    | j                   st        d      t        | j                   |      S )a  Returns the text in :attr:`text`
        from a given :class:`telegram.MessageEntity` of :attr:`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:`entities`.

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

        Raises:
            RuntimeError: If the gift info has no text.

        This GiftInfo has no 'text'.)rJ   RuntimeErrorr   )r"   rM   s     r$   parse_entityzGiftInfo.parse_entity  s(    ( yy=>>#DIIv66r%   typesc                 r    | j                   st        d      t        | j                   | j                  |      S )aO  
        Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`.
        It contains entities from this gift info's text 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:`entities`
            attribute, since it calculates the correct substring from the message text based on
            UTF-16 codepoints. See :attr:`parse_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 gift info has no text.

        rO   )rJ   rP   r   rE   )r"   rR   s     r$   parse_entitieszGiftInfo.parse_entities  s.    0 yy=>>%diiFFr%   )NNNNNNNr1   )r2   r3   r4   r5   r6   r   r   r7   r8   boolr   r   r   r   r9   r.   rQ   listdictrT   r:   r;   s   @r$   rB   rB      s   )V	I (,,048*."6:%) *.  } %SM	
 %-SM "$ sm 8M23 TN X&: 38 3(5/ 3Z 3 37= 7S 72GHT#Y$7 G4WZHZC[ Gr%   rB   c                   H     e Zd ZdZdZdddedededed	ee   f
 fd
Z xZ	S )AcceptedGiftTypesa  This object describes the types of gifts that can be gifted to a user or a chat.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal if their :attr:`unlimited_gifts`, :attr:`limited_gifts`,
    :attr:`unique_gifts` and :attr:`premium_subscription` are equal.

    .. versionadded:: 22.1

    Args:
        unlimited_gifts (:class:`bool`): :obj:`True`, if unlimited regular gifts are accepted.
        limited_gifts (:class:`bool`): :obj:`True`, if limited regular gifts are accepted.
        unique_gifts (:class:`bool`): :obj:`True`, if unique gifts or gifts that can be upgraded
            to unique for free are accepted.
        premium_subscription (:class:`bool`): :obj:`True`, if a Telegram Premium subscription
            is accepted.

    Attributes:
        unlimited_gifts (:class:`bool`): :obj:`True`, if unlimited regular gifts are accepted.
        limited_gifts (:class:`bool`): :obj:`True`, if limited regular gifts are accepted.
        unique_gifts (:class:`bool`): :obj:`True`, if unique gifts or gifts that can be upgraded
            to unique for free are accepted.
        premium_subscription (:class:`bool`): :obj:`True`, if a Telegram Premium subscription
            is accepted.

    )limited_giftspremium_subscriptionunique_giftsunlimited_giftsNr   r]   rZ   r\   r[   r   c                    t         |   |       || _        || _        || _        || _        | j                  | j                  | j                  | j
                  f| _        | j                          y r   )r   r   r]   rZ   r\   r[   r    r!   )r"   r]   rZ   r\   r[   r   r#   s         r$   r   zAcceptedGiftTypes.__init___  so     	J/%4#0".*>!   %%	
 	r%   )
r2   r3   r4   r5   r6   rU   r   r   r   r:   r;   s   @r$   rY   rY   =  sS    4I *.  	
 # X& r%   rY   N)r5   collections.abcr   typingr   r   telegram._chatr   telegram._files.stickerr   telegram._messageentityr   telegram._telegramobjectr	   telegram._utils.argumentparsingr
   r   r   telegram._utils.entitiesr   r   telegram._utils.typesr   telegramr   r   r=   rB   rY    r%   r$   <module>rj      sh   ( A $ *  + 1 3 b b Q *X3> X3v%3N %3PRG~ RGj8 8r%   