telegram.MessageEntity¶
-
class
telegram.MessageEntity(type, offset, length, url=None, user=None, language=None, custom_emoji_id=None, **_kwargs)¶ Bases:
telegram.base.TelegramObjectThis 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,offsetandlengthare equal.- Parameters
type (
str) –Type of the entity. Currently, can be mention (@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), custom_emoji (for inline custom emoji stickers).
New in version 13.14: added inline custom emoji
offset (
int) – Offset in UTF-16 code units to the start of the entity.length (
int) – Length of the entity in UTF-16 code units.url (
str, optional) – ForTEXT_LINKonly, url that will be opened after user taps on the text.user (
telegram.User, optional) – ForTEXT_MENTIONonly, the mentioned user.language (
str, optional) –- For
PREonly, the programming language of the entity text.
- custom_emoji_id (
str, optional): ForCUSTOM_EMOJIonly, unique identifier of the custom emoji. Use
telegram.Bot.get_custom_emoji_stickers()to get full information about the sticker.New in version 13.14.
- For
-
type¶ Type of the entity.
- Type
str
-
offset¶ Offset in UTF-16 code units to the start of the entity.
- Type
int
-
length¶ Length of the entity in UTF-16 code units.
- Type
int
-
url¶ Optional. Url that will be opened after user taps on the text.
- Type
str
-
user¶ Optional. The mentioned user.
- Type
-
language¶ Optional. Programming language of the entity text.
- Type
str
-
custom_emoji_id¶ Optional. Unique identifier of the custom emoji.
New in version 13.14.
- Type
str
-
ALL_TYPES: ClassVar[List[str]] = ['mention', 'hashtag', 'cashtag', 'phone_number', 'bot_command', 'url', 'email', 'bold', 'italic', 'code', 'pre', 'text_link', 'text_mention', 'underline', 'strikethrough', 'spoiler', 'custom_emoji']¶ telegram.constants.MESSAGEENTITY_ALL_TYPESList of all the types
-
BOLD: ClassVar[str] = 'bold'¶
-
BOT_COMMAND: ClassVar[str] = 'bot_command'¶
-
CASHTAG: ClassVar[str] = 'cashtag'¶
-
CODE: ClassVar[str] = 'code'¶
-
CUSTOM_EMOJI: ClassVar[str] = 'custom_emoji'¶ telegram.constants.MESSAGEENTITY_CUSTOM_EMOJINew in version 13.14.
-
EMAIL: ClassVar[str] = 'email'¶
-
HASHTAG: ClassVar[str] = 'hashtag'¶
-
ITALIC: ClassVar[str] = 'italic'¶
-
MENTION: ClassVar[str] = 'mention'¶
-
PHONE_NUMBER: ClassVar[str] = 'phone_number'¶
-
PRE: ClassVar[str] = 'pre'¶
-
SPOILER: ClassVar[str] = 'spoiler'¶ telegram.constants.MESSAGEENTITY_SPOILERNew in version 13.10.
-
STRIKETHROUGH: ClassVar[str] = 'strikethrough'¶
-
TEXT_LINK: ClassVar[str] = 'text_link'¶
-
TEXT_MENTION: ClassVar[str] = 'text_mention'¶
-
UNDERLINE: ClassVar[str] = 'underline'¶
-
URL: ClassVar[str] = 'url'¶
-
classmethod
de_json(data, bot)¶