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
¶ 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: telegram.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', 'cashtag', 'phone_number', 'bot_command', 'url', 'email', 'bold', 'italic', 'code', 'pre', 'text_link', 'text_mention']¶ List of all the types.
Type: List[ str
]
-
BOLD
= 'bold'¶ ‘bold’
Type: str
-
BOT_COMMAND
= 'bot_command'¶ ‘bot_command’
Type: str
-
CASHTAG
= 'cashtag'¶ ‘cashtag’
Type: str
-
CODE
= 'code'¶ ‘code’
Type: str
-
EMAIL
= 'email'¶ ‘email’
Type: str
-
HASHTAG
= 'hashtag'¶ ‘hashtag’
Type: str
-
ITALIC
= 'italic'¶ ‘italic’
Type: str
-
MENTION
= 'mention'¶ ‘mention’
Type: str
-
PHONE_NUMBER
= 'phone_number'¶ ‘phone_number’
Type: str
-
PRE
= 'pre'¶ ‘pre’
Type: str
-
TEXT_LINK
= 'text_link'¶ ‘text_link’
Type: str
-
TEXT_MENTION
= 'text_mention'¶ ‘text_mention’
Type: str
-
URL
= 'url'¶ ‘url’
Type: str
-