L i-DdZddlZddlmZddlmZmZmZm Z ddl m Z ddl m Z ddlmZddlmZdd lmZdd lmZdd lmZmZmZmZdd lmZdd lmZmZerddl m Z GddeZ!Gdde!Z"Gdde!Z#Gdde!Z$GddeZ%GddeZ&y)zCThis module contains objects that represent paid media in Telegram.N)Sequence) TYPE_CHECKINGFinalOptionalUnion) constants) PhotoSize)Video)TelegramObject)User)enum)de_json_optionalde_list_optionalparse_sequence_arg to_timedelta)get_timedelta_value)JSONDict TimePeriod)Botc&eZdZUdZdZej jZee e d< ej jZ ee e d< ej jZ ee e d< ddde d e ed dffd Zedd ed e dd dffd ZxZS) PaidMediaaDescribes 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. )typePREVIEWPHOTOVIDEON api_kwargsrrreturnct||tjtj |||_|j f|_|jyNr) super__init__r get_memberr PaidMediaTyper _id_attrs_freeze)selfrr __class__s Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/telegram/_paidmedia.pyr"zPaidMedia.__init__HsE J/)@)@$M )) databotrc|j|}|jt|jt|j t i}|tur8|jd|vr%||jdj||Sd|vr.|jdx}rtj|nd|d<t|)||S)aXConverts 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. rr+r,duration)secondsN) _parse_datarPaidMediaPreviewrPaidMediaPhotorPaidMediaVideorgetpopde_jsondtm timedeltar!)clsr+r,_class_mappingsr(s r)r7zPaidMedia.de_jsonTst$ KK) II~ II~6  )  0N B!$((6"23;;3;O O  AE*AU>ZHHr*)NNN)r>r?r@rArBrintrrr"propertyrr8r9r/rFrGs@r)r2r2rsB1I $ $)- R *. R}R R:& R X& R R"I(5cmm);#<=IIr*r2cpeZdZdZdZdddeddeeddffd Ze dd ed ed ddffd Z xZ S)r3a3 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. )photoNrrTr rrct|tj||j 5t ||_|j|j f|_dddy#1swYyxYwrM) r!r"rrrNrrTrr%)r'rTrr(s r)r"zPaidMediaPhoto.__init__sZ ioo*E ^^  50B50IDJ"ii4DN 5 5 5s .A((A1r+r,rc|j|}t|jdt||d<t|||S)NrTr.)r1rr5r r!r7r:r+r,r(s r)r7zPaidMediaPhoto.de_jsons?t$('):IsKW wDc22r*r=) r>r?r@rArBrrrr"rEr7rFrGs@r)r3r3sm"I *. 5 $ 5X& 5  5383(5/3EU33r*r3cjeZdZdZdZdddedeeddffdZe d d ed ed ddffd Z xZ S)r4a 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. )videoNrrYrrct|tj||j 5||_|j |j f|_dddy#1swYyxYwrM)r!r"rrrNrYrr%)r'rYrr(s r)r"zPaidMediaVideo.__init__sU ioo*E ^^  5 %DJ"ii4DN 5 5 5s %AA(r+r,rc|j|}t|jdt||d<t|||S)NrYr.)r1rr5r r!r7rWs r)r7zPaidMediaVideo.de_jsons?t$('):E3GW wDc22r*r=) r>r?r@rArBr rrr"rEr7rFrGs@r)r4r4sh"I *. 5 5X& 5  5383(5/3EU33r*r4c teZdZdZdZdddedeedee ddffd Z e dd e d ed ddffd Z xZ 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_countNrr_r^rrct||||_t||_|j|jf|_|j yr )r!r"r_rr^r%r&)r'r_r^rr(s r)r"zPaidMediaInfo.__init__sE J/)1CJ1O//4??; r*r+r,rc|j|}t|jdt||d<t|||S)Nr^r.)r1rr5rr!r7rWs r)r7zPaidMediaInfo.de_json"sAt$-dhh|.DiQTU\wDc22r*r=)r>r?r@rArBrQrrrrr"rEr7rFrGs@r)r]r]sv&-I*.  Y'  X&   383(5/3_33r*r]c neZdZdZdZdddddedeed dffd Ze dd ed ed d dffd Z xZ S)PaidMediaPurchasedaThis 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_userpaid_media_payloadNrrdr rerrct||||_||_|j|jf|_|j yr )r!r"rdrer%r&)r'rdrerr(s r)r"zPaidMediaPurchased.__init__@sC J/('9..$*A*AB r*r+r,rc|j|}tj|jd||d<t| ||S)Nfromr.rd)r1r r7r6r!rWs r)r7zPaidMediaPurchased.de_jsonNsBt$ LLdhhv.>CH[wDc22r*r=) r>r?r@rArBrCrrr"rEr7rFrGs@r)rcrc*sr&4I*.     X&   383(5/3EY33r*rc)'rAdatetimer8collections.abcrtypingrrrrtelegramrtelegram._files.photosizer telegram._files.videor telegram._telegramobjectr telegram._userr telegram._utilsr telegram._utils.argumentparsingrrrrtelegram._utils.datetimertelegram._utils.typesrrrrr2r3r4r]rcr*r)rvs&J$88/'3  96C3C3L7Iy7It&3Y&3R&3Y&3R)3N)3X)3)3r*