o
    ZzjFQ  ã                   @   sà   d 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 erFd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G dd„ deƒZdS )z:This module contains classes related to gifs sent by bots.é    )ÚSequence)ÚTYPE_CHECKING)ÚChat)Ú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ededededB f‡ fd	d
„Z‡  ZS )ÚGiftBackgrounda  This object describes the background of a gift.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal if their :attr:`center_color`, :attr:`edge_color` and :attr:`text_color` are
    equal.

    .. versionadded:: 22.6

    Args:
        center_color (:obj:`int`): Center color of the background in RGB format.
        edge_color (:obj:`int`): Edge color of the background in RGB format.
        text_color (:obj:`int`): Text color of the background in RGB format.

    Attributes:
        center_color (:obj:`int`): Center color of the background in RGB format.
        edge_color (:obj:`int`): Edge color of the background in RGB format.
        text_color (:obj:`int`): Text color of the background in RGB format.

    )Úcenter_colorÚ
edge_colorÚ
text_colorN©Ú
api_kwargsr   r   r   r   c                   s>   t ƒ j|d� || _|| _|| _| j| j| jf| _|  ¡  d S ©Nr   )ÚsuperÚ__init__r   r   r   Ú	_id_attrsÚ_freeze)Úselfr   r   r   r   ©Ú	__class__© úJ/var/www/kodo/tsheker/venv/lib/python3.10/site-packages/telegram/_gifts.pyr   @   s   ýzGiftBackground.__init__)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__Úintr   r   Ú__classcell__r   r   r   r   r   %   s    úþýüúr   c                       sÆ   e Zd ZdZdZ										dddœdededededB d	edB d
edB dedB dedB dedB de	dB de
dB de
dB dedB dedB f‡ fdd„Zeddedddd f‡ fdd„ƒZ‡  ZS )ÚGiftak  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 by all users; for limited gifts only.
        remaining_count (:obj:`int`, optional): The number of remaining gifts of this type that can
            be sent by all users; 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
        personal_total_count (:obj:`int`, optional): The total number of gifts of this type that
            can be sent by the bot; for limited gifts only.

            .. versionadded:: 22.6
        personal_remaining_count (:obj:`int`, optional): The number of remaining gifts of this type
            that can be sent by the bot; for limited gifts only.

            .. versionadded:: 22.6
        background (:class:`GiftBackground`, optional): Background of the gift.

            .. versionadded:: 22.6
        is_premium (:obj:`bool`, optional): :obj:`True`, if the gift can only be purchased by
            Telegram Premium subscribers.

            .. versionadded:: 22.6
        has_colors (:obj:`bool`, optional): :obj:`True`, if the gift can be used (after being
            upgraded) to customize a user's appearance.

            .. versionadded:: 22.6
        unique_gift_variant_count (:obj:`int`, optional): The total number of different unique
            gifts that can be obtained by upgrading the gift.

            .. versionadded:: 22.6

    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 by all users; for limited gifts only.
        remaining_count (:obj:`int`): Optional. The number of remaining gifts of this type that can
            be sent by all users; 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
        personal_total_count (:obj:`int`): Optional. The total number of gifts of this type that
            can be sent by the bot; for limited gifts only.

            .. versionadded:: 22.6
        personal_remaining_count (:obj:`int`): Optional. The number of remaining gifts of this type
            that can be sent by the bot; for limited gifts only.

            .. versionadded:: 22.6
        background (:class:`GiftBackground`): Optional. Background of the gift.

            .. versionadded:: 22.6
        is_premium (:obj:`bool`): Optional. :obj:`True`, if the gift can only be purchased by
            Telegram Premium subscribers.

            .. versionadded:: 22.6
        has_colors (:obj:`bool`): Optional. :obj:`True`, if the gift can be used (after being
            upgraded) to customize a user's appearance.

            .. versionadded:: 22.6
        unique_gift_variant_count (:obj:`int`): Optional. The total number of different unique
            gifts that can be obtained by upgrading the gift.

            .. versionadded:: 22.6

    )Ú
backgroundÚ
has_colorsÚidÚ
is_premiumÚpersonal_remaining_countÚpersonal_total_countÚpublisher_chatÚremaining_countÚ
star_countÚstickerÚtotal_countÚunique_gift_variant_countÚupgrade_star_countNr   r)   r0   r/   r1   r.   r3   r-   r,   r+   r'   r*   r(   r2   r   c                   sr   t ƒ j|d� || _|| _|| _|| _|| _|| _|| _|| _	|	| _
|
| _|| _|| _|| _| jf| _|  ¡  d S r   )r   r   r)   r0   r/   r1   r.   r3   r-   r,   r+   r'   r*   r(   r2   r   r   )r   r)   r0   r/   r1   r.   r3   r-   r,   r+   r'   r*   r(   r2   r   r   r   r   r   Â   s    
zGift.__init__ÚdataÚbotú
Bot | NoneÚreturnc                    s\   |   |¡}t| d¡t|ƒ|d< t| d¡t|ƒ|d< t| d¡t|ƒ|d< tƒ j||d�S )ú,See :meth:`telegram.TelegramObject.de_json`.r0   r-   r'   ©r4   r5   )Ú_parse_datar   Úgetr   r   r   r   Úde_json©Úclsr4   r5   r   r   r   r<   ç   s
   
zGift.de_json)
NNNNNNNNNN©N)r   r    r!   r"   r#   Ústrr   r$   r   r   Úboolr   r   Úclassmethodr<   r%   r   r   r   r   r&   V   s\    [òðþýüûúùø	÷
öõôóòð%&r&   c                       s\   e Zd ZdZdZddœdee dedB f‡ fdd„Ze	dd	ed
ddd f‡ fdd„ƒZ
‡  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   rD   r   c                   s.   t ƒ j|d� t|ƒ| _| jf| _|  ¡  d S r   )r   r   r
   rD   r   r   )r   rD   r   r   r   r   r     s   

zGifts.__init__r4   r5   r6   r7   c                    s0   |   |¡}t| d¡t|ƒ|d< tƒ j||d�S )r8   rD   r9   )r:   r	   r;   r&   r   r<   r=   r   r   r   r<     s   
zGifts.de_jsonr?   )r   r    r!   r"   r#   r   r&   r   r   rB   r<   r%   r   r   r   r   rC   ò   s    üþü&rC   c                       sî   e Zd ZdZdZ									dddœdededB dedB dedB d	edB d
edB de	e
 dB dedB dedB dedB dedB f‡ fdd„Zeddedddd f‡ fdd„ƒZde
defdd„Zddee dB 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 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.
        is_upgrade_separate (:obj:`bool`, optional): :obj:`True`, if the gift's upgrade was
            purchased after the gift was sent.

            .. versionadded:: 22.6
        unique_gift_number (:obj:`int`, optional): Unique number reserved for this gift when
            upgraded. See the number field in :class:`~telegram.UniqueGift`.

            .. versionadded:: 22.6

    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 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.
        is_upgrade_separate (:obj:`bool`): Optional. :obj:`True`, if the gift's upgrade was
            purchased after the gift was sent.

            .. versionadded:: 22.6
        unique_gift_number (:obj:`int`): Optional. Unique number reserved for this gift when
            upgraded. See the number field in :class:`~telegram.UniqueGift`.

            .. versionadded:: 22.6

    )
Úcan_be_upgradedÚconvert_star_countÚentitiesÚgiftÚ
is_privateÚis_upgrade_separateÚowned_gift_idÚprepaid_upgrade_star_countÚtextÚunique_gift_numberNr   rI   rL   rG   rM   rF   rN   rH   rJ   rO   rK   r   c                   sd   t ƒ j|d� || _|| _|| _|| _|| _|| _t|ƒ| _	|| _
|	| _|
| _| jf| _|  ¡  d S r   )r   r   rI   rL   rG   rM   rF   rN   r
   rH   rJ   rO   rK   r   r   )r   rI   rL   rG   rM   rF   rN   rH   rJ   rO   rK   r   r   r   r   r   c  s   

zGiftInfo.__init__r4   r5   r6   r7   c                    sF   |   |¡}t| d¡t|ƒ|d< t| d¡t|ƒ|d< tƒ j||d�S )r8   rI   rH   r9   )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'.)rN   ÚRuntimeErrorr   )r   rP   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.

        rQ   )rN   rR   r   rH   )r   rT   r   r   r   Úparse_entities§  s   zGiftInfo.parse_entities)	NNNNNNNNNr?   )r   r    r!   r"   r#   r&   r@   r$   rA   r   r   r   r   rB   r<   rS   ÚlistÚdictrU   r%   r   r   r   r   rE     sR    ;õóþýüûúù
ø	÷
öõó!	,rE   c                       sH   e Zd ZdZdZddœdedededed	ed
edB 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`, :attr:`premium_subscription` and :attr:`gifts_from_channels` are equal.

    .. versionadded:: 22.1
    .. versionchanged:: 22.6
        :attr:`gifts_from_channels` is now considered for equality checks.

    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.
        gifts_from_channels (:obj:`bool`): :obj:`True`, if transfers of unique gifts from channels
            are accepted

            .. versionadded:: 22.6

    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.
        gifts_from_channels (:obj:`bool`): :obj:`True`, if transfers of unique gifts from channels
            are accepted

            .. versionadded:: 22.6

    )Úgifts_from_channelsÚlimited_giftsÚpremium_subscriptionÚunique_giftsÚunlimited_giftsNr   r]   rZ   r\   r[   rY   r   c                   sR   t ƒ j|d� || _|| _|| _|| _|| _| j| j| j| j| jf| _|  ¡  d S r   )	r   r   r]   rZ   r\   r[   rY   r   r   )r   r]   rZ   r\   r[   rY   r   r   r   r   r   ò  s   
ûzAcceptedGiftTypes.__init__)	r   r    r!   r"   r#   rA   r   r   r%   r   r   r   r   rX   Å  s"    $øþýüûúørX   N)r"   Úcollections.abcr   Útypingr   Útelegram._chatr   Útelegram._files.stickerr   Útelegram._messageentityr   Útelegram._telegramobjectr   Útelegram._utils.argumentparsingr   r	   r
   Útelegram._utils.entitiesr   r   Útelegram._utils.typesr   Útelegramr   r   r&   rC   rE   rX   r   r   r   r   Ú<module>   s&   1 ( ,