Game(title, description, photo, text=None, text_entities=None, animation=None, **kwargs)¶
This object represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers.
Title of the game.
Description of the game.
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 set_game_score, or manually edited using edit_message_text.
Optional. Special entities that appear in text, such as usernames, URLs, bot commands, etc.
Optional. Animation that will be displayed in the game message in chats. Upload via BotFather.
- title (
str) – Title of the game.
- description (
str) – Description of the game.
- photo (List[
telegram.PhotoSize]) – Photo that will be displayed in the game message in chats.
- text (
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 set_game_score, or manually edited using edit_message_text. 0-4096 characters. Also found as
- text_entities (List[
telegram.MessageEntity], optional) – Special entities that appear in text, such as usernames, URLs, bot commands, etc.
- animation (
telegram.Animation, optional) – Animation that will be displayed in the game message in chats. Upload via BotFather.
str. It contains entities from this message filtered by their
typeattribute as the key, and the text that each entity belongs to as the value of the
This method should always be used instead of the
text_entitiesattribute, since it calculates the correct substring from the message text based on UTF-16 codepoints. See
parse_text_entityfor more info.
Parameters: types (List[
str], optional) – List of
MessageEntitytypes as strings. If the
typeattribute of an entity is contained in this list, it will be returned. Defaults to
Returns: A dictionary of entities mapped to the text that belongs to them, calculated based on UTF-16 codepoints. Return type: Dict[
Returns the text from a given
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.textwith the offset and length.)
Parameters: entity (
telegram.MessageEntity) – The entity to extract the text from. It must be an entity that belongs to this message.
Returns: The text of the given entity. Return type: