
    Yi                          S r SSKJr  SSKJrJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJr  SSKJr  SS	KJr  SS
KJr  \(       a  SSKJr   " S S\5      rg)z?This module contains an object that represents a Telegram Game.    )Sequence)TYPE_CHECKINGOptional)	Animation)	PhotoSize)MessageEntity)TelegramObject)parse_sequence_arg)TextEncoding)JSONDict)Botc                      ^  \ rS rSrSrSr   SSS.S\S\S\\   S	\	\   S
\	\\
      S\	\   S\	\   4U 4S jjjjr\SS\	\   S\	S   S\	S    4U 4S jjj5       rS\
S\4S jrSS\	\\      S\\
\4   4S jjrSrU =r$ )Game#   a1
  
This object represents a game. Use `BotFather <https://t.me/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 <https://t.me/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 <https://t.me/BotFather>`_.

)	animationdescriptionphototexttext_entitiestitleN
api_kwargsr   r   r   r   r   r   r   c                   > [         TU ]  US9  Xl        X l        [	        U5      U l        X@l        [	        U5      U l        X`l        U R                  U R                  U R
                  4U l	        U R                  5         g )Nr   )super__init__r   r   r
   r   r   r   r   	_id_attrs_freeze)	selfr   r   r   r   r   r   r   	__class__s	           ?/app/.venv/lib/python3.13/site-packages/telegram/_games/game.pyr   Game.__init__e   sh     	J/
 +,>u,E
#'	8J=8Y.7**d&6&6

C    databotr   returnc                 F  > U R                  U5      nU(       d  g[        R                  " UR                  S5      U5      US'   [        R                  " UR                  S5      U5      US'   [
        R                  " UR                  S5      U5      US'   [        TU ]  XS9$ )z,See :meth:`telegram.TelegramObject.de_json`.Nr   r   r   )r#   r$   )_parse_datar   de_listgetr   r   de_jsonr   )clsr#   r$   r   s      r    r*   Game.de_json~   s     t$!))$((7*;SAW - 5 5dhh6OQT U_%--dhh{.CSI[wD22r"   entityc                     U R                   (       d  [        S5      eU R                   R                  [        R                  5      nX!R
                  S-  UR
                  UR                  -   S-   nUR                  [        R                  5      $ )a@  Returns 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.

zThis Game has no 'text'.   )r   RuntimeErrorencoder   	UTF_16_LEoffsetlengthdecode)r   r-   entity_texts      r    parse_text_entityGame.parse_text_entity   sn    & yy9::ii&&|'='=>!--!"3v}}v}}7TXY6YZ!!,"8"899r"   typesc                     Uc  [         R                  nU R                   Vs0 s H&  nUR                  U;   d  M  X R	                  U5      _M(     sn$ s  snf )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_TYPESr   typer7   )r   r9   r-   s      r    parse_text_entitiesGame.parse_text_entities   s]    . =!++E ,,
,{{e# 3F**622,
 	
 
s
   AA)r   r   r   r   r   r   r   )NNN)N)__name__
__module____qualname____firstlineno____doc__	__slots__strr   r   r   r   r   r   r   classmethodr*   r7   listdictr=   __static_attributes____classcell__)r   s   @r    r   r   #   s   6pI #;?)- *.  	"	
 sm   78 I& X& 2 38H- 3HUO 3xX^O_ 3 3: :# :6
$s))< 
]\_M_H` 
 
r"   r   N)rC   collections.abcr   typingr   r   telegram._files.animationr   telegram._files.photosizer   telegram._messageentityr   telegram._telegramobjectr	   telegram._utils.argumentparsingr
   telegram._utils.stringsr   telegram._utils.typesr   telegramr   r    r"   r    <module>rV      s:   & F $ * / / 1 3 > 0 *b
> b
r"   