Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions telegram/_games/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ class Game(TelegramObject):
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`.
text_entities (List[:class:`telegram.MessageEntity`]): Optional. Special entities that
text_entities (List[:class:`telegram.MessageEntity`]): Special entities that
appear in text, such as usernames, URLs, bot commands, etc.
This list is empty if the message does not contain text entities.
animation (:class:`telegram.Animation`): Optional. Animation that will be displayed in the
game message in chats. Upload via `BotFather <https://t.me/BotFather>`_.

Expand Down Expand Up @@ -182,7 +183,7 @@ def parse_text_entities(self, types: List[str] = None) -> Dict[MessageEntity, st

return {
entity: self.parse_text_entity(entity)
for entity in (self.text_entities or [])
for entity in self.text_entities
if entity.type in types
}

Expand Down
28 changes: 14 additions & 14 deletions telegram/_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Message(TelegramObject):
entities (List[:class:`telegram.MessageEntity`], optional): For text messages, special
entities like usernames, URLs, bot commands, etc. that appear in the text. See
:attr:`parse_entity` and :attr:`parse_entities` methods for how to use properly.
caption_entities (List[:class:`telegram.MessageEntity`]): Optional. For Messages with a
caption_entities (List[:class:`telegram.MessageEntity`], optional): For messages with a
Caption. Special entities like usernames, URLs, bot commands, etc. that appear in the
caption. See :attr:`Message.parse_caption_entity` and :attr:`parse_caption_entities`
methods for how to use properly.
Expand Down Expand Up @@ -280,27 +280,29 @@ class Message(TelegramObject):
media_group_id (:obj:`str`): Optional. The unique identifier of a media message group this
message belongs to.
text (:obj:`str`): Optional. The actual UTF-8 text of the message.
entities (List[:class:`telegram.MessageEntity`]): Optional. Special entities like
entities (List[:class:`telegram.MessageEntity`]): Special entities like
usernames, URLs, bot commands, etc. that appear in the text. See
:attr:`Message.parse_entity` and :attr:`parse_entities` methods for how to use
properly.
caption_entities (List[:class:`telegram.MessageEntity`]): Optional. Special entities like
properly. This list is empty if the message does not contain entities.
caption_entities (List[:class:`telegram.MessageEntity`]): Special entities like
usernames, URLs, bot commands, etc. that appear in the caption. See
:attr:`Message.parse_caption_entity` and :attr:`parse_caption_entities` methods for how
to use properly.
to use properly. This list is empty if the message does not contain caption entities.
audio (:class:`telegram.Audio`): Optional. Information about the file.
document (:class:`telegram.Document`): Optional. Information about the file.
animation (:class:`telegram.Animation`) Optional. Information about the file.
For backward compatibility, when this field is set, the document field will also be
set.
game (:class:`telegram.Game`): Optional. Information about the game.
photo (List[:class:`telegram.PhotoSize`]): Optional. Available sizes of the photo.
photo (List[:class:`telegram.PhotoSize`]): Available sizes of the photo.
This list is empty if the message does not contain a photo.
sticker (:class:`telegram.Sticker`): Optional. Information about the sticker.
video (:class:`telegram.Video`): Optional. Information about the video.
voice (:class:`telegram.Voice`): Optional. Information about the file.
video_note (:class:`telegram.VideoNote`): Optional. Information about the video message.
new_chat_members (List[:class:`telegram.User`]): Optional. Information about new members to
the chat. (the bot itself may be one of these members).
new_chat_members (List[:class:`telegram.User`]): Information about new members to
the chat. The bot itself may be one of these members.
This list is empty if the message does not contain new chat members.
caption (:obj:`str`): Optional. Caption for the document, photo or video,
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH`
characters.
Expand All @@ -310,8 +312,8 @@ class Message(TelegramObject):
left_chat_member (:class:`telegram.User`): Optional. Information about the user that left
the group. (this member may be the bot itself).
new_chat_title (:obj:`str`): Optional. A chat title was changed to this value.
new_chat_photo (List[:class:`telegram.PhotoSize`]): Optional. A chat photo was changed to
this value.
new_chat_photo (List[:class:`telegram.PhotoSize`]): A chat photo was changed to
this value. This list is empty if the message does not contain a new chat photo.
delete_chat_photo (:obj:`bool`): Optional. The chat photo was deleted.
group_chat_created (:obj:`bool`): Optional. The group has been created.
supergroup_chat_created (:obj:`bool`): Optional. The supergroup has been created.
Expand Down Expand Up @@ -2724,9 +2726,7 @@ def parse_entities(self, types: List[str] = None) -> Dict[MessageEntity, str]:
types = MessageEntity.ALL_TYPES

return {
entity: self.parse_entity(entity)
for entity in (self.entities or [])
if entity.type in types
entity: self.parse_entity(entity) for entity in self.entities if entity.type in types
}

def parse_caption_entities(self, types: List[str] = None) -> Dict[MessageEntity, str]:
Expand Down Expand Up @@ -2757,7 +2757,7 @@ def parse_caption_entities(self, types: List[str] = None) -> Dict[MessageEntity,

return {
entity: self.parse_caption_entity(entity)
for entity in (self.caption_entities or [])
for entity in self.caption_entities
if entity.type in types
}

Expand Down
10 changes: 7 additions & 3 deletions telegram/_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ class Poll(TelegramObject):
correct_option_id (:obj:`int`): Optional. Identifier of the correct answer option.
explanation (:obj:`str`): Optional. Text that is shown when a user chooses an incorrect
answer or taps on the lamp icon in a quiz-style poll.
explanation_entities (List[:class:`telegram.MessageEntity`]): Optional. Special entities
explanation_entities (List[:class:`telegram.MessageEntity`]): Special entities
like usernames, URLs, bot commands, etc. that appear in the :attr:`explanation`.
This list is empty if the message does not contain explanation entities.

.. versionchanged:: 20.0
This attribute is now always a (possibly empty) list and never :obj:`None`.
open_period (:obj:`int`): Optional. Amount of time in seconds the poll will be active
after creation.
close_date (:obj:`datetime.datetime`): Optional. Point in time when the poll will be
Expand Down Expand Up @@ -196,7 +200,7 @@ def __init__(
self.allows_multiple_answers = allows_multiple_answers
self.correct_option_id = correct_option_id
self.explanation = explanation
self.explanation_entities = explanation_entities
self.explanation_entities = explanation_entities or []
self.open_period = open_period
self.close_date = close_date

Expand Down Expand Up @@ -283,7 +287,7 @@ def parse_explanation_entities(self, types: List[str] = None) -> Dict[MessageEnt

return {
entity: self.parse_explanation_entity(entity)
for entity in (self.explanation_entities or [])
for entity in self.explanation_entities
if entity.type in types
}

Expand Down