L i dZddlmZddlmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZmZmZdd lmZdd lmZerdd lmZGd d e Zy)z?This module contains an object that represents a Telegram Game.)Sequence) TYPE_CHECKINGOptional) Animation) PhotoSize) MessageEntity)TelegramObject)de_json_optionalde_list_optionalparse_sequence_arg) TextEncoding)JSONDict)BotceZdZdZdZ ddddededeedeed eee d ee d ee ffd Z e dd e dedddffd Zde defdZddeeedee effdZxZS)Gamea This object represents a game. Use `BotFather `_ to create and edit games, their short names will act as unique identifiers. Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their :attr:`title`, :attr:`description` and :attr:`photo` are equal. Args: title (:obj:`str`): Title of the game. description (:obj:`str`): Description of the game. photo (Sequence[:class:`telegram.PhotoSize`]): Photo that will be displayed in the game message in chats. .. versionchanged:: 20.0 |sequenceclassargs| text (:obj:`str`, optional): Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls :meth:`telegram.Bot.set_game_score`, or manually edited using :meth:`telegram.Bot.edit_message_text`. 0-:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` characters. text_entities (Sequence[:class:`telegram.MessageEntity`], optional): Special entities that appear in text, such as usernames, URLs, bot commands, etc. .. versionchanged:: 20.0 |sequenceclassargs| animation (:class:`telegram.Animation`, optional): Animation that will be displayed in the game message in chats. Upload via `BotFather `_. Attributes: title (:obj:`str`): Title of the game. description (:obj:`str`): Description of the game. photo (tuple[:class:`telegram.PhotoSize`]): Photo that will be displayed in the game message in chats. .. versionchanged:: 20.0 |tupleclassattrs| text (:obj:`str`): Optional. Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls :meth:`telegram.Bot.set_game_score`, or manually edited using :meth:`telegram.Bot.edit_message_text`. 0-:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` characters. text_entities (tuple[:class:`telegram.MessageEntity`]): Optional. Special entities that appear in text, such as usernames, URLs, bot commands, etc. This tuple is empty if the message does not contain text entities. .. versionchanged:: 20.0 |tupleclassattrs| animation (:class:`telegram.Animation`): Optional. Animation that will be displayed in the game message in chats. Upload via `BotFather `_. ) animation descriptionphototext text_entitiestitleN api_kwargsrrrrrrrct||||_||_t ||_||_t ||_||_|j|j|j f|_ |jy)Nr) super__init__rrr rrrr _id_attrs_freeze) selfrrrrrrr __class__s Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/telegram/_games/game.pyrz Game.__init__fsp J/ +,>u,E #' 8J=8Y.7**d&6&6 C databotrreturnc|j|}t|jdt||d<t|jdt||d<t |jdt ||d<t|!||S)z,See :meth:`telegram.TelegramObject.de_json`.rrr)r#r$) _parse_datar getrrr rrde_json)clsr#r$r s r!r)z Game.de_jsonszt$('):IsKW 0/1JM[^ __,TXXk-BIsS[wDc22r"entityc|js td|jjtj}||j dz|j |j zdz}|jtjS)aReturns the text from a given :class:`telegram.MessageEntity`. 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 this message. Returns: :obj:`str`: The text of the given entity. Raises: RuntimeError: If this game has no text. zThis Game has no 'text'.)r RuntimeErrorencoder UTF_16_LEoffsetlengthdecode)rr+ entity_texts r!parse_text_entityzGame.parse_text_entitysp&yy9: :ii&&|'='=> !&--!"3v}}v}}7TXY6YZ !!,"8"899r"typesc|tj}|jDcic]"}|j|vr||j |$c}Scc}w)a] Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`. It contains entities from this message filtered by their :attr:`~telegram.MessageEntity.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:`text_entities` attribute, since it calculates the correct substring from the message text based on UTF-16 codepoints. See :attr:`parse_text_entity` for more info. Args: types (list[:obj:`str`], optional): List of :class:`telegram.MessageEntity` types as strings. If the :attr:`~telegram.MessageEntity.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. )r ALL_TYPESrtyper5)rr6r+s r!parse_text_entitieszGame.parse_text_entitiessX. =!++E,, {{e# D**62 2   s'A )NNN)N)__name__ __module__ __qualname____doc__ __slots__strrrrrrrr classmethodr)r5listdictr: __classcell__)r s@r!rr$s6pI#;?)-*. "  sm    78 I&X&2383(5/3V33: :#:6 $s))< ]\_M_H` r"rN)r>collections.abcrtypingrrtelegram._files.animationrtelegram._files.photosizertelegram._messageentityrtelegram._telegramobjectr telegram._utils.argumentparsingr r r telegram._utils.stringsr telegram._utils.typesrtelegramrrr"r!rPs=&F$*//13bb0*_ >_ r"