telegram.MessageEntity¶
-
class
telegram.
MessageEntity
(type, offset, length, url=None, user=None, **kwargs)¶ Bases:
telegram.base.TelegramObject
This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
-
type
¶ str
– Type of the entity.
-
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. Url that will be opened after user taps on the text.
-
user
¶ telegram.User
– Optional. The mentioned user.
Parameters: - type (
str
) – Type of the entity. Can be mention (@username), hashtag, bot_command, url, email, bold (bold text), italic (italic text), 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. - length (
int
) – Length of the entity in UTF-16 code units. - url (
str
, optional) – For “text_link” only, url that will be opened after usertaps on the text. - user (
telegram.User
, optional) – For “text_mention” only, the mentioned user.
-
ALL_TYPES
= ['mention', 'hashtag', 'bot_command', 'url', 'email', 'bold', 'italic', 'code', 'pre', 'text_link', 'text_mention']¶ List[
str
] – List of all the types.
-
BOLD
= 'bold'¶ str
– ‘bold’
-
BOT_COMMAND
= 'bot_command'¶ str
– ‘bot_command’
-
CODE
= 'code'¶ str
– ‘code’
-
EMAIL
= 'email'¶ str
– ‘email’
-
HASHTAG
= 'hashtag'¶ str
– ‘hashtag’
-
ITALIC
= 'italic'¶ str
– ‘italic’
-
MENTION
= 'mention'¶ str
– ‘mention’
-
PRE
= 'pre'¶ str
– ‘pre’
-
TEXT_LINK
= 'text_link'¶ str
– ‘text_link’
-
TEXT_MENTION
= 'text_mention'¶ str
– ‘text_mention’
-
URL
= 'url'¶ str
– ‘url’
-