# telegram.MessageEntity

class telegram.MessageEntity(type, offset, length, url=None, user=None, language=None, **_kwargs)

  Bases: `telegram.base.TelegramObject`

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

    - 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 user taps on the text.

    - user (`telegram.User`, optional) – For `TEXT_MENTION` only, the mentioned user.

    - language (`str`, optional) – For `PRE` only, the programming language of the entity text.

  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`

  language

    Optional. Programming language of the entity text.

    Type

      `str`

  ALL_TYPES = ['mention', 'hashtag', 'cashtag', 'phone_number', 'bot_command', 'url', 'email', 'bold', 'italic', 'code', 'pre', 'text_link', 'text_mention', 'underline', 'strikethrough', 'spoiler']

    `telegram.constants.MESSAGEENTITY_ALL_TYPES`

    List of all the types

  BOLD = 'bold'

    `telegram.constants.MESSAGEENTITY_BOLD`

  BOT_COMMAND = 'bot_command'

    `telegram.constants.MESSAGEENTITY_BOT_COMMAND`

  CASHTAG = 'cashtag'

    `telegram.constants.MESSAGEENTITY_CASHTAG`

  CODE = 'code'

    `telegram.constants.MESSAGEENTITY_CODE`

  EMAIL = 'email'

    `telegram.constants.MESSAGEENTITY_EMAIL`

  HASHTAG = 'hashtag'

    `telegram.constants.MESSAGEENTITY_HASHTAG`

  ITALIC = 'italic'

    `telegram.constants.MESSAGEENTITY_ITALIC`

  MENTION = 'mention'

    `telegram.constants.MESSAGEENTITY_MENTION`

  PHONE_NUMBER = 'phone_number'

    `telegram.constants.MESSAGEENTITY_PHONE_NUMBER`

  PRE = 'pre'

    `telegram.constants.MESSAGEENTITY_PRE`

  SPOILER = 'spoiler'

    `telegram.constants.MESSAGEENTITY_SPOILER`

    New in version 13.10.

  STRIKETHROUGH = 'strikethrough'

    `telegram.constants.MESSAGEENTITY_STRIKETHROUGH`

  TEXT_LINK = 'text_link'

    `telegram.constants.MESSAGEENTITY_TEXT_LINK`

  TEXT_MENTION = 'text_mention'

    `telegram.constants.MESSAGEENTITY_TEXT_MENTION`

  UNDERLINE = 'underline'

    `telegram.constants.MESSAGEENTITY_UNDERLINE`

  URL = 'url'

    `telegram.constants.MESSAGEENTITY_URL`

  classmethod de_json(data, bot)

    See `telegram.TelegramObject.de_json()`.