telegram.MessageEntity¶
- class telegram.MessageEntity(*args, **kwargs)[source]¶
Bases:
telegram.TelegramObject
This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their
type
,offset
andlength
are equal.- Parameters
type (
str
) – Type of the entity. Can beMENTION
(@username),HASHTAG
,BOT_COMMAND
,URL
,EMAIL
,PHONE_NUMBER
,BOLD
(bold text),ITALIC
(italic text),STRIKETHROUGH
,SPOILER
(spoiler message),CODE
(monowidth string),PRE
(monowidth block),TEXT_LINK
(for clickable text URLs),TEXT_MENTION
(for users without usernames).offset (
int
) – Offset in UTF-16 code units to the start of the entity.url (
str
, optional) – ForTEXT_LINK
only, url that will be opened after user taps on the text.user (
telegram.User
, optional) – ForTEXT_MENTION
only, the mentioned user.language (
str
, optional) – ForPRE
only, the programming language of the entity text.
- ALL_TYPES = [<MessageEntityType.MENTION>, <MessageEntityType.HASHTAG>, <MessageEntityType.CASHTAG>, <MessageEntityType.PHONE_NUMBER>, <MessageEntityType.BOT_COMMAND>, <MessageEntityType.URL>, <MessageEntityType.EMAIL>, <MessageEntityType.BOLD>, <MessageEntityType.ITALIC>, <MessageEntityType.CODE>, <MessageEntityType.PRE>, <MessageEntityType.TEXT_LINK>, <MessageEntityType.TEXT_MENTION>, <MessageEntityType.UNDERLINE>, <MessageEntityType.STRIKETHROUGH>, <MessageEntityType.SPOILER>][source]¶
A list of all available message entity types.
- Type
List[
str
]
- SPOILER = 'spoiler'[source]¶
telegram.constants.MessageEntityType.SPOILER
New in version 13.10.