o
    ZzjA3  ã                   @   s4  d Z ddl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 dd
lmZ ddlmZ ddlmZmZmZmZ ddlmZ ddlmZmZ er`d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%G dd„ deƒZ&G dd„ deƒZ'dS )zCThis module contains objects that represent paid media in Telegram.é    N)ÚSequence)ÚTYPE_CHECKINGÚFinal)Ú	constants)Ú	LivePhoto)Ú	PhotoSize)ÚVideo)ÚTelegramObject)ÚUser)Úenum)Úde_json_optionalÚde_list_optionalÚparse_sequence_argÚto_timedelta)Úget_timedelta_value)ÚJSONDictÚ
TimePeriod)ÚBotc                       s¶   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< 	 ejjZee	 e
d< 	 ejjZee	 e
d< 	 ddœd	e	d
edB ddf‡ fdd„Zeddedddd f‡ fdd„ƒZ‡  ZS )Ú	PaidMediaaø  Describes the paid media added to a message. Currently, it can be one of:

    * :class:`telegram.PaidMediaPreview`
    * :class:`telegram.PaidMediaPhoto`
    * :class:`telegram.PaidMediaVideo`

    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:: 21.4

    Args:
        type (:obj:`str`): Type of the paid media.

    Attributes:
        type (:obj:`str`): Type of the paid media.
    )ÚtypeÚPREVIEWÚPHOTOÚVIDEOÚ
LIVE_PHOTON©Ú
api_kwargsr   r   Úreturnc                   s6   t ƒ j|d� t tj||¡| _| jf| _|  ¡  d S ©Nr   )	ÚsuperÚ__init__r   Ú
get_memberr   ÚPaidMediaTyper   Ú	_id_attrsÚ_freeze)Úselfr   r   ©Ú	__class__© úN/var/www/kodo/tsheker/venv/lib/python3.10/site-packages/telegram/_paidmedia.pyr   K   s   
zPaidMedia.__init__ÚdataÚbotú
Bot | Nonec                    sŽ   |   |¡}| jt| jt| jt| jti}| t	u r*| 
d¡|v r*|| d¡ j||d�S d|v r?| 
d¡ }r;tj|d�nd|d< tƒ j||d�S )aX  Converts JSON data to the appropriate :class:`PaidMedia` 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*   Úduration)ÚsecondsN)Ú_parse_datar   ÚPaidMediaPreviewr   ÚPaidMediaPhotor   ÚPaidMediaVideor   ÚPaidMediaLivePhotor   ÚgetÚpopÚde_jsonÚdtmÚ	timedeltar   )Úclsr)   r*   Ú_class_mappingÚsr%   r'   r(   r6   W   s   
ü"zPaidMedia.de_json©N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r!   r   r   ÚstrÚ__annotations__r   r   r   r   r   Úclassmethodr6   Ú__classcell__r'   r'   r%   r(   r   -   s*   
 üþüû&r   c                       st   e Zd ZdZdZ			dddœdedB dedB dedB dedB d	df
‡ fd
d„Ze	d	ee
jB dB fdd„ƒZ‡  ZS )r0   a·  The paid media isn't available before the payment.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`width`, :attr:`height`, and :attr:`duration`
    are equal.

    .. versionadded:: 21.4

    .. versionchanged:: v22.2
       As part of the migration to representing time periods using ``datetime.timedelta``,
       equality comparison now considers integer durations and equivalent timedeltas as equal.

    Args:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PREVIEW`.
        width (:obj:`int`, optional): Media width as defined by the sender.
        height (:obj:`int`, optional): Media height as defined by the sender.
        duration (:obj:`int` | :class:`datetime.timedelta`, optional): Duration of the media in
            seconds as defined by the sender.

            .. versionchanged:: v22.2
                |time-period-input|

    Attributes:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PREVIEW`.
        width (:obj:`int`): Optional. Media width as defined by the sender.
        height (:obj:`int`): Optional. Media height as defined by the sender.
        duration (:obj:`int` | :class:`datetime.timedelta`): Optional. Duration of the media in
            seconds as defined by the sender.

            .. deprecated:: v22.2
                |time-period-int-deprecated|
    )Ú	_durationÚheightÚwidthNr   rH   rG   r-   r   r   c                   sl   t ƒ jtj|d� |  ¡ � || _|| _t|ƒ| _| j	| j| j| jf| _
W d   ƒ d S 1 s/w   Y  d S ©N)r   r   )r   r   r   r   Ú	_unfrozenrH   rG   r   rF   r   r"   )r$   rH   rG   r-   r   r%   r'   r(   r   š   s   

"ûzPaidMediaPreview.__init__c                 C   s   t | jdd�S )Nr-   )Ú	attribute)r   rF   )r$   r'   r'   r(   r-   «   s   zPaidMediaPreview.duration)NNN)r=   r>   r?   r@   rA   Úintr   r   r   Úpropertyr7   r8   r-   rE   r'   r'   r%   r(   r0   v   s*    !üúþýüúù"r0   c                       s`   e Zd ZdZdZddœded dedB ddf‡ fd	d
„Zeddedddd f‡ fdd„ƒZ	‡  Z
S )r1   a3  
    The paid media is a photo.

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

    .. versionadded:: 21.4

    Args:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PHOTO`.
        photo (Sequence[:class:`telegram.PhotoSize`]): The photo.

    Attributes:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.PHOTO`.
        photo (tuple[:class:`telegram.PhotoSize`]): The photo.
    )ÚphotoNr   rN   r   r   r   c                   sX   t ƒ jtj|d� |  ¡ � t|ƒ| _| j| jf| _W d   ƒ d S 1 s%w   Y  d S rI   )	r   r   r   r   rJ   r   rN   r   r"   )r$   rN   r   r%   r'   r(   r   Ä   s
   

"ýzPaidMediaPhoto.__init__r)   r*   r+   c                    ó0   |   |¡}t| d¡t|ƒ|d< tƒ j||d�S )NrN   r,   )r/   r   r4   r   r   r6   ©r9   r)   r*   r%   r'   r(   r6   Ñ   ó   
zPaidMediaPhoto.de_jsonr<   )r=   r>   r?   r@   rA   r   r   r   rD   r6   rE   r'   r'   r%   r(   r1   °   s    üþüû&r1   c                       ó\   e Zd ZdZdZddœdededB ddf‡ fdd	„Zedd
edddd f‡ fdd„ƒZ	‡  Z
S )r2   a  
    The paid media is a video.

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

    .. versionadded:: 21.4

    Args:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.VIDEO`.
        video (:class:`telegram.Video`): The video.

    Attributes:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.VIDEO`.
        video (:class:`telegram.Video`): The video.
    )ÚvideoNr   rS   r   r   c                   óT   t ƒ jtj|d� |  ¡ � || _| j| jf| _W d   ƒ d S 1 s#w   Y  d S rI   )r   r   r   r   rJ   rS   r   r"   )r$   rS   r   r%   r'   r(   r   í   s
   
"ýzPaidMediaVideo.__init__r)   r*   r+   c                    rO   )NrS   r,   )r/   r   r4   r   r   r6   rP   r%   r'   r(   r6   ú   rQ   zPaidMediaVideo.de_jsonr<   )r=   r>   r?   r@   rA   r   r   r   rD   r6   rE   r'   r'   r%   r(   r2   Ù   s    üþüû&r2   c                       rR   )r3   a?  
    The paid media is a live photo.

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

    .. versionadded:: 22.8

    Args:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.LIVE_PHOTO`
        live_photo (:class:`telegram.LivePhoto`): The photo.

    Attributes:
        type (:obj:`str`): Type of the paid media, always :tg-const:`telegram.PaidMedia.LIVE_PHOTO`
        live_photo (:class:`telegram.LivePhoto`): The photo.

    )Ú
live_photoNr   rU   r   r   c                   rT   rI   )r   r   r   r   rJ   rU   r   r"   )r$   rU   r   r%   r'   r(   r     s
   
"þzPaidMediaLivePhoto.__init__r)   r*   r+   c                    rO   )NrU   r,   )r/   r   r4   r   r   r6   rP   r%   r'   r(   r6   #  rQ   zPaidMediaLivePhoto.de_jsonr<   )r=   r>   r?   r@   rA   r   r   r   rD   r6   rE   r'   r'   r%   r(   r3     s    üþüû&r3   c                	       sd   e Zd ZdZdZddœdedee dedB ddf‡ fd	d
„Z	e
ddedddd f‡ fdd„ƒZ‡  ZS )ÚPaidMediaInfoaÉ  
    Describes the paid media added to a message.

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

    .. versionadded:: 21.4

    Args:
        star_count (:obj:`int`): The number of Telegram Stars that must be paid to buy access to
            the media.
        paid_media (Sequence[:class:`telegram.PaidMedia`]): Information about the paid media.

    Attributes:
        star_count (:obj:`int`): The number of Telegram Stars that must be paid to buy access to
            the media.
        paid_media (tuple[:class:`telegram.PaidMedia`]): Information about the paid media.
    )Ú
paid_mediaÚ
star_countNr   rX   rW   r   r   c                   s8   t ƒ j|d� || _t|ƒ| _| j| jf| _|  ¡  d S r   )r   r   rX   r   rW   r"   r#   )r$   rX   rW   r   r%   r'   r(   r   A  s
   
zPaidMediaInfo.__init__r)   r*   r+   c                    rO   )NrW   r,   )r/   r   r4   r   r   r6   rP   r%   r'   r(   r6   O  rQ   zPaidMediaInfo.de_jsonr<   )r=   r>   r?   r@   rA   rL   r   r   r   r   rD   r6   rE   r'   r'   r%   r(   rV   +  s    ûþýûú&rV   c                	       s`   e Zd ZdZdZddœdddededB d	df‡ fd
d„Zeddeddd	d f‡ fdd„ƒZ	‡  Z
S )ÚPaidMediaPurchasedaÁ  This object contains information about a paid media purchase.

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

    Note:
        In Python :keyword:`from` is a reserved word. Use :paramref:`from_user` instead.

    .. versionadded:: 21.6

    Args:
        from_user (:class:`telegram.User`): User who purchased the media.
        paid_media_payload (:obj:`str`): Bot-specified paid media payload.

    Attributes:
        from_user (:class:`telegram.User`): User who purchased the media.
        paid_media_payload (:obj:`str`): Bot-specified paid media payload.
    )Ú	from_userÚpaid_media_payloadNr   rZ   r
   r[   r   r   c                   s4   t ƒ j|d� || _|| _| j| jf| _|  ¡  d S r   )r   r   rZ   r[   r"   r#   )r$   rZ   r[   r   r%   r'   r(   r   m  s
   zPaidMediaPurchased.__init__r)   r*   r+   c                    s2   |   |¡}tj| d¡|d�|d< tƒ j||d�S )NÚfromr,   rZ   )r/   r
   r6   r5   r   rP   r%   r'   r(   r6   {  s   
zPaidMediaPurchased.de_jsonr<   )r=   r>   r?   r@   rA   rB   r   r   rD   r6   rE   r'   r'   r%   r(   rY   W  s    ûþýûú&rY   )(r@   Údatetimer7   Úcollections.abcr   Útypingr   r   Útelegramr   Útelegram._files.livephotor   Útelegram._files.photosizer   Útelegram._files.videor   Útelegram._telegramobjectr	   Útelegram._userr
   Útelegram._utilsr   Útelegram._utils.argumentparsingr   r   r   r   Útelegram._utils.datetimer   Útelegram._utils.typesr   r   r   r   r0   r1   r2   r3   rV   rY   r'   r'   r'   r(   Ú<module>   s.   I:))),