L i9dZddlmZddlmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZmZmZdd lmZmZdd lmZerdd lmZGd d e ZGdde ZGdde ZGdde Zy)z:This module contains classes related to gifs sent by bots.)Sequence) TYPE_CHECKINGOptional)Chat)Sticker) MessageEntity)TelegramObject)de_json_optionalde_list_optionalparse_sequence_arg)parse_message_entitiesparse_message_entity)JSONDict)BotceZdZdZdZ ddddedededeed eed eed ee d ee ffd Z e dde dedddffd Z xZS)GiftaThis 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 publisher_chat (:class:`telegram.Chat`, optional): Information about the chat that published the gift. .. versionadded:: 22.4 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 publisher_chat (:class:`telegram.Chat`): Optional. Information about the chat that published the gift. .. versionadded:: 22.4 )idpublisher_chatremaining_count star_countsticker total_countupgrade_star_countN api_kwargsrrrrrrrrct ||||_||_||_||_||_||_||_|jf|_ |jyNr) super__init__rrrrrrr _id_attrs_freeze) selfrrrrrrrr __class__s U/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/telegram/_gifts.pyrz Gift.__init__]s` J/ ' )*5.=1C.<'' databotrreturnc|j|}t|jdt||d<t|jdt||d<t |||S),See :meth:`telegram.TelegramObject.de_json`.rrr&r') _parse_datar getrrrde_jsonclsr&r'r#s r$r.z Gift.de_jsonvs`t$*488I+>MY!1$((;K2LdTW!X wDc22r%)NNNNN)__name__ __module__ __qualname____doc__ __slots__strrintrrrr classmethodr. __classcell__r#s@r$rr%s+ZI&*)-,0)-*.   c]  "# %SM!X&2383(5/3V33r%rcleZdZdZdZdddeedeeffdZ e d ded ed d dffd Z xZ S)GiftsavThis 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. )giftsNrr>rct||t||_|jf|_|j yr)rrr r>r r!)r"r>rr#s r$rzGifts.__init__s7 J/'9%'@ ** r%r&r'rr(c|j|}t|jdt||d<t|||S)r*r>r+)r,r r-rrr.r/s r$r.z Gifts.de_jsonsAt$('):D#FW wDc22r%r1) r2r3r4r5r6rrrrrr9r.r:r;s@r$r=r=sa I *. ~ X& 383(5/3W33r%r=ceZdZdZdZ ddddedeedeedeed ee d eed ee e d ee d ee ffdZ edde dedddffd Zde defdZddeeedee effdZxZS)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_upgradedconvert_star_countentitiesgift is_private owned_gift_idprepaid_upgrade_star_counttextNrrFrHrDrIrCrJrErGrc t || ||_||_||_||_||_||_t||_ ||_ |jf|_ |jyr) rrrFrHrDrIrCrJr rErGr r!) r"rFrHrDrIrCrJrErGrr#s r$rzGiftInfo.__init__sl J/ ,91C9S'/>#' 3Eh3O *4)) r%r&r'rr(c|j|}t|jdt||d<t |jdt ||d<t |||S)r*rFrEr+)r,r r-rr rrr.r/s r$r.zGiftInfo.de_jsons^t$'(8$DV +DHHZ,@-QTUZwDc22r%entityc\|js tdt|j|S)aReturns 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'.)rJ RuntimeErrorr)r"rMs r$ parse_entityzGiftInfo.parse_entitys((yy=> >#DIIv66r%typescr|js tdt|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. rO)rJrPr rE)r"rRs r$parse_entitieszGiftInfo.parse_entitiess.0yy=> >%diiFFr%)NNNNNNNr1)r2r3r4r5r6rrr7r8boolrrrrr9r.rQlistdictrTr:r;s@r$rBrBs)V I(,,048*."6:%)*. }%SM  %-SM  "$ sm8M23TNX&:383(5/3Z337=7S72GHT#Y$7G4 WZHZC[Gr%rBc HeZdZdZdZdddedededed eef fd ZxZ S) AcceptedGiftTypesaThis 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_giftspremium_subscription unique_giftsunlimited_giftsNrr]rZr\r[rct||||_||_||_||_|j|j|j|j f|_|jyr)rrr]rZr\r[r r!)r"r]rZr\r[rr#s r$rzAcceptedGiftTypes.__init___so J/%4#0".*>!         % %   r%) r2r3r4r5r6rUrrrr:r;s@r$rYrY=sS4I*.  # X&r%rYN)r5collections.abcrtypingrrtelegram._chatrtelegram._files.stickerrtelegram._messageentityrtelegram._telegramobjectr telegram._utils.argumentparsingr r r telegram._utils.entitiesr rtelegram._utils.typesrtelegramrrr=rBrYr%r$rjsh(A$*+13bbQ*X3>X3v%3N%3PRG~RGj88r%