MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / MessageEntity

Class MessageEntity

src/telegram/_messageentity.py:42–465  ·  view source on GitHub ↗

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 :attr:`type`, :attr:`offset` and :attr:`length` are equal.

Source from the content-addressed store, hash-verified

40
41
42class MessageEntity(TelegramObject):
43 """
44 This object represents one special entity in a text message. For example, hashtags,
45 usernames, URLs, etc.
46
47 Objects of this class are comparable in terms of equality. Two objects of this class are
48 considered equal, if their :attr:`type`, :attr:`offset` and :attr:`length` are equal.
49
50 Args:
51 type (:obj:`str`): Type of the entity. Can be :attr:`MENTION` (``@username``),
52 :attr:`HASHTAG` (``#hashtag`` or ``#hashtag@chatusername``), :attr:`CASHTAG` (``$USD``
53 or ``USD@chatusername``), :attr:`BOT_COMMAND` (``/start@jobs_bot``), :attr:`URL`
54 (``https://telegram.org``), :attr:`EMAIL` (``do-not-reply@telegram.org``),
55 :attr:`PHONE_NUMBER` (``+1-212-555-0123``),
56 :attr:`BOLD` (**bold text**), :attr:`ITALIC` (*italic text*), :attr:`UNDERLINE`
57 (underlined text), :attr:`STRIKETHROUGH`, :attr:`SPOILER` (spoiler message),
58 :attr:`BLOCKQUOTE` (block quotation), :attr:`CODE` (monowidth string), :attr:`PRE`
59 (monowidth block), :attr:`TEXT_LINK` (for clickable text URLs), :attr:`TEXT_MENTION`
60 (for users without usernames), :attr:`CUSTOM_EMOJI` (for inline custom emoji stickers)
61 or :attr:`DATE_TIME` (for formatted date and time).
62
63 .. versionadded:: 20.0
64 Added inline custom emoji
65
66 .. versionadded:: 20.8
67 Added block quotation
68
69 .. versionadded:: 22.7
70 Added date_time
71 offset (:obj:`int`): Offset in UTF-16 code units to the start of the entity.
72 length (:obj:`int`): Length of the entity in UTF-16 code units.
73 url (:obj:`str`, optional): For :attr:`TEXT_LINK` only, url that will be opened after
74 user taps on the text.
75 user (:class:`telegram.User`, optional): For :attr:`TEXT_MENTION` only, the mentioned
76 user.
77 language (:obj:`str`, optional): For :attr:`PRE` only, the programming language of
78 the entity text.
79 custom_emoji_id (:obj:`str`, optional): For :attr:`CUSTOM_EMOJI` only, unique identifier
80 of the custom emoji. Use :meth:`telegram.Bot.get_custom_emoji_stickers` to get full
81 information about the sticker.
82
83 .. versionadded:: 20.0
84 date_time_format (:obj:`str`, optional): For :attr:`DATE_TIME` only, the string that
85 defines the formatting of the date and time. See `date-time entity formatting
86 <https://core.telegram.org/bots/api#date-time-entity-formatting>`_ for more details and
87 :class:`telegram.constants.MessageEntityDateTimeFormats` for all possible formats.
88
89 .. versionadded:: 22.7
90 unix_time (:class:`datetime.datetime`, optional): For :attr:`DATE_TIME` only, the time
91 associated with the entity.
92 |datetime_localization|
93
94 .. versionadded:: 22.7
95 Attributes:
96 type (:obj:`str`): Type of the entity. Can be :attr:`MENTION` (``@username``),
97 :attr:`HASHTAG` (``#hashtag`` or ``#hashtag@chatusername``), :attr:`CASHTAG` (``$USD``
98 or ``USD@chatusername``), :attr:`BOT_COMMAND` (``/start@jobs_bot``), :attr:`URL`
99 (``https://telegram.org``), :attr:`EMAIL` (``do-not-reply@telegram.org``),

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…