o
    "h7                     @   s   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mZmZ ddlmZmZ dd	lmZ erBdd
lmZ G dd deZG dd deZG dd deZG dd deZdS )z:This module contains classes related to gifs sent by bots.    )Sequence)TYPE_CHECKINGOptional)Sticker)MessageEntity)TelegramObject)de_json_optionalde_list_optionalparse_sequence_arg)parse_message_entitiesparse_message_entity)JSONDict)Botc                       s   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	 f fddZ
edde	ded dd f fddZ  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

    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

    )idremaining_count
star_countstickertotal_countupgrade_star_countN
api_kwargsr   r   r   r   r   r   r   c                   sH   t  j|d || _|| _|| _|| _|| _|| _| jf| _| 	  d S Nr   )
super__init__r   r   r   r   r   r   	_id_attrs_freeze)selfr   r   r   r   r   r   r   	__class__ B/var/www/html/venv/lib/python3.10/site-packages/telegram/_gifts.pyr   P   s   
zGift.__init__databotr   returnc                    0   |  |}t|dt||d< t j||dS ),See :meth:`telegram.TelegramObject.de_json`.r   r"   r#   )_parse_datar   getr   r   de_jsonclsr"   r#   r   r    r!   r*   g      
zGift.de_json)NNNN)__name__
__module____qualname____doc__	__slots__strr   intr   r   r   classmethodr*   __classcell__r    r    r   r!   r   #   s2    #		*r   c                       s`   e Zd ZdZdZdddee dee f fddZ	e
dd	ed
ed dd f fddZ  ZS )Giftsat  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   r9   r   c                   s.   t  j|d t|| _| jf| _|   d S r   )r   r   r
   r9   r   r   )r   r9   r   r   r    r!   r      s   

zGifts.__init__r"   r#   r   r$   c                    r%   )r&   r9   r'   )r(   r	   r)   r   r   r*   r+   r   r    r!   r*      r-   zGifts.de_jsonr.   )r/   r0   r1   r2   r3   r   r   r   r   r   r6   r*   r7   r    r    r   r!   r8   p   s    *r8   c                       s   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dZeddeded dd f fddZdedefddZddeee  deeef fddZ  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   r>   r@   r<   rA   r;   rB   r=   r?   r   c	          
         sX   t  j|	d || _|| _|| _|| _|| _|| _t|| _	|| _
| jf| _|   d S r   )r   r   r>   r@   r<   rA   r;   rB   r
   r=   r?   r   r   )
r   r>   r@   r<   rA   r;   rB   r=   r?   r   r   r    r!   r      s   

zGiftInfo.__init__r"   r#   r   r$   c                    sF   |  |}t|dt||d< t|dt||d< t j||dS )r&   r>   r=   r'   )r(   r   r)   r   r	   r   r   r*   r+   r   r    r!   r*      s   
zGiftInfo.de_jsonentityc                 C   s   | 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'.)rB   RuntimeErrorr   )r   rC   r    r    r!   parse_entity   s   zGiftInfo.parse_entitytypesc                 C   s   | 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.

        rD   )rB   rE   r   r=   )r   rG   r    r    r!   parse_entities  s   zGiftInfo.parse_entities)NNNNNNNr.   )r/   r0   r1   r2   r3   r   r   r4   r5   boolr   r   r   r   r6   r*   rF   listdictrH   r7   r    r    r   r!   r:      sF    +
	"	,r:   c                       sD   e Zd ZdZdZdddedededed	ee f
 fd
dZ  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   rP   rM   rO   rN   r   c                   sH   t  j|d || _|| _|| _|| _| j| j| j| jf| _|   d S r   )r   r   rP   rM   rO   rN   r   r   )r   rP   rM   rO   rN   r   r   r    r!   r   O  s   	zAcceptedGiftTypes.__init__)
r/   r0   r1   r2   r3   rI   r   r   r   r7   r    r    r   r!   rL   -  s    rL   N)r2   collections.abcr   typingr   r   telegram._files.stickerr   telegram._messageentityr   telegram._telegramobjectr   telegram._utils.argumentparsingr   r	   r
   telegram._utils.entitiesr   r   telegram._utils.typesr   telegramr   r   r8   r:   rL   r    r    r    r!   <module>   s    M( 