
    YPiJ                     ,   d Z ddlZddlmZ ddl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mZ ddl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)z8This module contains objects that represent owned gifts.    N)Sequence)TYPE_CHECKINGFinalOptional)	constants)Gift)MessageEntity)TelegramObject)
UniqueGift)User)enum)de_json_optionalde_list_optionalparse_sequence_arg)extract_tzinfo_from_defaultsfrom_timestamp)parse_message_entitiesparse_message_entity)JSONDict)Botc                        e Zd ZU dZdZej                  j                  Zee	   e
d<   	 ej                  j                  Zee	   e
d<   	 ddde	dee   d	df fd
Zeddeded   d	d f fd       Z xZS )	OwnedGifta  This object describes a gift received and owned by a user or a chat. Currently, it
    can be one of:

    * :class:`telegram.OwnedGiftRegular`
    * :class:`telegram.OwnedGiftUnique`

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

    .. versionadded:: 22.1

    Args:
        type (:obj:`str`): Type of the owned gift.

    Attributes:
        type (:obj:`str`): Type of the owned gift.
    )typeREGULARUNIQUEN
api_kwargsr   r   returnc                    t         |   |       t        j                  t        j
                  ||      | _        | j                  f| _        | j                          y Nr   )	super__init__r   
get_memberr   OwnedGiftTyper   	_id_attrs_freeze)selfr   r   	__class__s      I/root/twitch_bot/venv/lib/python3.12/site-packages/telegram/_ownedgift.pyr"   zOwnedGift.__init__C   sE     	J/)@)@$M	))    databotr   c                    | j                  |      }| j                  t        | j                  t        i}| t
        u r8|j                  d      |v r%||j                  d         j                  ||      S t        | !  ||      S )aX  Converts JSON data to the appropriate :class:`OwnedGift` object, i.e. takes
        care of selecting the correct subclass.

        Args:
            data (dict[:obj:`str`, ...]): The JSON data.
            bot (:class:`telegram.Bot`, optional): The bot associated with this object.

        Returns:
            The Telegram object.

        r   r+   r,   )
_parse_datar   OwnedGiftRegularr   OwnedGiftUniquer   getpopde_jsonr!   )clsr+   r,   _class_mappingr(   s       r)   r4   zOwnedGift.de_jsonO   s     t$ KK)JJ6

 ) 0N B!$((6"23;;3;OOwDc22r*   N)__name__
__module____qualname____doc__	__slots__r   r$   r   r   str__annotations__r   r   r   r"   classmethodr4   __classcell__r(   s   @r)   r   r   )   s    $ I#1199GU3Z9;"0077FE#J7: *.	

 X&	

 

 38 3(5/ 3[ 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
   f fd	Zedd
e
ded   dd f fd       Z xZS )
OwnedGiftsau  Contains the list of gifts received and owned by 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:`total_count` and :attr:`gifts` are equal.

    .. versionadded:: 22.1

    Args:
        total_count (:obj:`int`): The total number of gifts owned by the user or the chat.
        gifts (Sequence[:class:`telegram.OwnedGift`]): The list of gifts.
        next_offset (:obj:`str`, optional): Offset for the next request. If empty,
            then there are no more results.

    Attributes:
        total_count (:obj:`int`): The total number of gifts owned by the user or the chat.
        gifts (Sequence[:class:`telegram.OwnedGift`]): The list of gifts.
        next_offset (:obj:`str`): Optional. Offset for the next request. If empty,
            then there are no more results.
    )giftsnext_offsettotal_countNr   rF   rD   rE   r   c                    t         |   |       || _        t        |      | _        || _        | j                  | j                  f| _        | j                          y r    )r!   r"   rF   r   rD   rE   r%   r&   )r'   rF   rD   rE   r   r(   s        r)   r"   zOwnedGifts.__init__   sP     	J/ +,>u,E
*5**DJJ7r*   r+   r,   r   r   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )z,See :meth:`telegram.TelegramObject.de_json`.rD   r.   )r/   r   r2   r   r!   r4   )r5   r+   r,   r(   s      r)   r4   zOwnedGifts.de_json   sA     t$('):IsKWwDc22r*   r7   )r8   r9   r:   r;   r<   intr   r   r   r=   r   r"   r?   r4   r@   rA   s   @r)   rC   rC   i   s    (I &*	 *. 	" c]	 X&" 38 3(5/ 3\ 3 3r*   rC   c                   :    e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 ddddedej                  dee	   dee
   d	ee	   d
eee      dee   dee   dee   dee   dee   dee   dee   dd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 )r0   a  Describes a regular gift owned by 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:`gift` and :attr:`send_date` are equal.

    .. versionadded:: 22.1

    Args:
        gift (:class:`telegram.Gift`): Information about the regular gift.
        owned_gift_id (:obj:`str`, optional): Unique identifier of the gift for the bot; for
            gifts received on behalf of business accounts only.
        sender_user (:class:`telegram.User`, optional): Sender of the gift if it is a known user.
        send_date (:obj:`datetime.datetime`): Date the gift was sent as :class:`datetime.datetime`.
            |datetime_localization|.
        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.
        is_saved (:obj:`bool`, optional): :obj:`True`, if the gift is displayed on the account's
            profile page; for gifts received on behalf of business accounts only.
        can_be_upgraded (:obj:`bool`, optional): :obj:`True`, if the gift can be upgraded to a
            unique gift; for gifts received on behalf of business accounts only.
        was_refunded (:obj:`bool`, optional): :obj:`True`, if the gift was refunded and isn't
            available anymore.
        convert_star_count (:obj:`int`, optional): Number of Telegram Stars that can be
            claimed by the receiver instead of the gift; omitted if the gift cannot be converted
            to Telegram Stars.
        prepaid_upgrade_star_count (:obj:`int`, optional): Number of Telegram Stars that were
            paid by the sender for the ability to upgrade the gift.

    Attributes:
        type (:obj:`str`): Type of the gift, always :attr:`~telegram.OwnedGift.REGULAR`.
        gift (:class:`telegram.Gift`): Information about the regular gift.
        owned_gift_id (:obj:`str`): Optional. Unique identifier of the gift for the bot; for
            gifts received on behalf of business accounts only.
        sender_user (:class:`telegram.User`): Optional. Sender of the gift if it is a known user.
        send_date (:obj:`datetime.datetime`): Date the gift was sent as :class:`datetime.datetime`.
            |datetime_localization|.
        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.
        is_saved (:obj:`bool`): Optional. :obj:`True`, if the gift is displayed on the account's
            profile page; for gifts received on behalf of business accounts only.
        can_be_upgraded (:obj:`bool`): Optional. :obj:`True`, if the gift can be upgraded to a
            unique gift; for gifts received on behalf of business accounts only.
        was_refunded (:obj:`bool`): Optional. :obj:`True`, if the gift was refunded and isn't
            available anymore.
        convert_star_count (:obj:`int`): Optional. Number of Telegram Stars that can be
            claimed by the receiver instead of the gift; omitted if the gift cannot be converted
            to Telegram Stars.
        prepaid_upgrade_star_count (:obj:`int`): Optional. Number of Telegram Stars that were
            paid by the sender for the ability to upgrade the gift.

    )can_be_upgradedconvert_star_countentitiesgift
is_privateis_savedowned_gift_idprepaid_upgrade_star_count	send_datesender_usertextwas_refundedNr   rN   rS   rQ   rT   rU   rM   rO   rP   rK   rV   rL   rR   r   r   c                   t         |   t        j                  |       | j	                         5  || _        || _        || _        || _        || _	        t        |      | _        || _        || _        |	| _        |
| _        || _        || _        | j$                  | j
                  | j                  f| _        d d d        y # 1 sw Y   y xY wN)r   r   )r!   r"   r   r   	_unfrozenrN   rS   rQ   rT   rU   r   rM   rO   rP   rK   rV   rL   rR   r   r%   )r'   rN   rS   rQ   rT   rU   rM   rO   rP   rK   rV   rL   rR   r   r(   s                 r)   r"   zOwnedGiftRegular.__init__   s    " 	i//JG^^ 	D"DI+4DN0=D/:D'+DI7I(7SDM.8DO,4DM3BD 0<D5GD#=WD+"iiDNNCDN	D 	D 	Ds   BC  C	r+   r,   r   c                 n   | j                  |      }t        |      }t        |j                  d      |      |d<   t	        |j                  d      t
        |      |d<   t	        |j                  d      t        |      |d<   t        |j                  d      t        |      |d<   t        | )  ||      S )'See :meth:`telegram.OwnedGift.de_json`.rS   tzinforT   rN   rM   r.   )r/   r   r   r2   r   r   r   r   r	   r!   r4   r5   r+   r,   
loc_tzinfor(   s       r)   r4   zOwnedGiftRegular.de_json  s     t$1#6
*488K+@T[.txx/FcR]'(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 ``OwnedGiftRegular.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 owned gift has no text.

        $This OwnedGiftRegular has no 'text'.)rU   RuntimeErrorr   )r'   r`   s     r)   parse_entityzOwnedGiftRegular.parse_entity  s(    ( yyEFF#DIIv66r*   typesc                 r    | j                   st        d      t        | j                   | j                  |      S )aQ  
        Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`.
        It contains entities from this owned gift'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 owned gift has no text.

        rb   )rU   rc   r   rM   )r'   re   s     r)   parse_entitieszOwnedGiftRegular.parse_entities1  s.    0 yyEFF%diiFFr*   )
NNNNNNNNNNr7   )r8   r9   r:   r;   r<   r   dtmdatetimer   r=   r   r   r	   boolrI   r   r"   r?   r4   rd   listdictrg   r@   rA   s   @r)   r0   r0      s|   8tI& (,&*"6:%)#'*.'+,048!D *.!D!D <<!D  }	!D
 d^!D sm!D 8M23!D TN!D 4.!D "$!D tn!D %SM!D %-SM!D X&!D  
!!DF 
38 
3(5/ 
3EW 
3 
37= 7S 72GHT#Y$7 G4WZHZC[ Gr*   r0   c                        e Zd ZdZdZ	 	 	 	 	 	 ddddedej                  dee	   dee
   d	ee   d
ee   dee   deej                     dee   ddf fdZeddeded   dd f fd       Z xZS )r1   ah  
    Describes a unique gift received and owned by 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:`gift` and :attr:`send_date` are equal.

    .. versionadded:: 22.1

    Args:
        gift (:class:`telegram.UniqueGift`): Information about the unique gift.
        owned_gift_id (:obj:`str`, optional): Unique identifier of the received gift for the
            bot; for gifts received on behalf of business accounts only.
        sender_user (:class:`telegram.User`, optional): Sender of the gift if it is a known user.
        send_date (:obj:`datetime.datetime`): Date the gift was sent as :class:`datetime.datetime`.
            |datetime_localization|
        is_saved (:obj:`bool`, optional): :obj:`True`, if the gift is displayed on the account's
            profile page; for gifts received on behalf of business accounts only.
        can_be_transferred (:obj:`bool`, optional): :obj:`True`, if the gift can be transferred to
            another owner; for gifts received on behalf of business accounts only.
        transfer_star_count (:obj:`int`, optional): Number of Telegram Stars that must be paid
            to transfer the gift; omitted if the bot cannot transfer the gift.
        next_transfer_date (:obj:`datetime.datetime`, optional): Date when the gift can be
            transferred. If it's in the past, then the gift can be transferred now.
            |datetime_localization|
            .. versionadded:: 22.3

    Attributes:
        type (:obj:`str`): Type of the owned gift, always :tg-const:`~telegram.OwnedGift.UNIQUE`.
        gift (:class:`telegram.UniqueGift`): Information about the unique gift.
        owned_gift_id (:obj:`str`): Optional. Unique identifier of the received gift for the
            bot; for gifts received on behalf of business accounts only.
        sender_user (:class:`telegram.User`): Optional. Sender of the gift if it is a known user.
        send_date (:obj:`datetime.datetime`): Date the gift was sent as :class:`datetime.datetime`.
            |datetime_localization|
        is_saved (:obj:`bool`): Optional. :obj:`True`, if the gift is displayed on the account's
            profile page; for gifts received on behalf of business accounts only.
        can_be_transferred (:obj:`bool`): Optional. :obj:`True`, if the gift can be transferred to
            another owner; for gifts received on behalf of business accounts only.
        transfer_star_count (:obj:`int`): Optional. Number of Telegram Stars that must be paid
            to transfer the gift; omitted if the bot cannot transfer the gift.
        next_transfer_date (:obj:`datetime.datetime`): Optional. Date when the gift can be
            transferred. If it's in the past, then the gift can be transferred now.
            |datetime_localization|
            .. versionadded:: 22.3
    )can_be_transferredrN   rP   next_transfer_daterQ   rS   rT   transfer_star_countNr   rN   rS   rQ   rT   rP   rn   rp   ro   r   r   c	                N   t         
|   t        j                  |	       | j	                         5  || _        || _        || _        || _        || _	        || _
        || _        || _        | j                  | j
                  | j                  f| _        d d d        y # 1 sw Y   y xY wrX   )r!   r"   r   r   rY   rN   rS   rQ   rT   rP   rn   rp   ro   r   r%   )r'   rN   rS   rQ   rT   rP   rn   rp   ro   r   r(   s             r)   r"   zOwnedGiftUnique.__init__  s     	i..:F^^ 
	D$(DI+4DN0=D/:D,4DM6HD#6ID$>PD#"iiDNNCDN
	D 
	D 
	Ds   A!BB$r+   r,   r   c                 f   | j                  |      }t        |      }t        |j                  d      |      |d<   t	        |j                  d      t
        |      |d<   t	        |j                  d      t        |      |d<   t        |j                  d      |      |d<   t        | !  ||      S )r[   rS   r\   rT   rN   ro   r.   )	r/   r   r   r2   r   r   r   r!   r4   r^   s       r)   r4   zOwnedGiftUnique.de_json  s     t$1#6
*488K+@T[.txx/FcR]'(8*cJV%3HH)*:&
!" wDc22r*   )NNNNNNr7   )r8   r9   r:   r;   r<   r   rh   ri   r   r=   r   rj   rI   r   r"   r?   r4   r@   rA   s   @r)   r1   r1   O  s    ,\	I (,&*#'-1-159D *.DD <<D  }	D
 d^D 4.D %TND &c]D %S\\2D X&D 
D6 38 3(5/ 3EV 3 3r*   r1   )(r;   ri   rh   collections.abcr   typingr   r   r   telegramr   telegram._giftsr   telegram._messageentityr	   telegram._telegramobjectr
   telegram._uniquegiftr   telegram._userr   telegram._utilsr   telegram._utils.argumentparsingr   r   r   telegram._utils.datetimer   r   telegram._utils.entitiesr   r   telegram._utils.typesr   r   r   rC   r0   r1    r*   r)   <module>r      sy   & ?  $ 1 1    1 3 +    b b Q Q *=3 =3@23 23jnGy nGbb3i b3r*   