telegram.MessageEntity¶
- class telegram.MessageEntity(type, offset, length, url=None, user=None, language=None, custom_emoji_id=None, *, api_kwargs=None)[source]¶
Bases:
telegram.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 of the entity. 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 20.0: Added inline custom emoji
offset (
int) – Offset in UTF-16 code units to the start of the entity.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) – ForPREonly, the programming language of the entity text.custom_emoji_id (
str, optional) –For
CUSTOM_EMOJIonly, unique identifier of the custom emoji. Usetelegram.Bot.get_custom_emoji_stickers()to get full information about the sticker.New in version 20.0.
- type[source]¶
Type of the entity. 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 20.0: Added inline custom emoji
- Type
- url[source]¶
Optional. For
TEXT_LINKonly, url that will be opened after user taps on the text.- Type
- user[source]¶
Optional. For
TEXT_MENTIONonly, the mentioned user.- Type
- custom_emoji_id[source]¶
Optional. For
CUSTOM_EMOJIonly, unique identifier of the custom emoji. Usetelegram.Bot.get_custom_emoji_stickers()to get full information about the sticker.New in version 20.0.
- Type
- 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>, <MessageEntityType.CUSTOM_EMOJI>][source]¶
A list of all available message entity types.
- Type
List[
str]
- CUSTOM_EMOJI = 'custom_emoji'[source]¶
telegram.constants.MessageEntityType.CUSTOM_EMOJINew in version 20.0.
- SPOILER = 'spoiler'[source]¶
telegram.constants.MessageEntityType.SPOILERNew in version 13.10.