MessageEntity

class aiogram.types.message_entity.MessageEntity(type: String, offset: Integer, length: Integer, url: Optional[String] = None, user: Optional[User] = None, language: Optional[String] = None, custom_emoji_id: Optional[String] = None, **kwargs)[source]

Bases: TelegramObject

This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.

https://core.telegram.org/bots/api#messageentity

Deserialize object

Parameters
  • conf

  • kwargs

get_text(text)[source]

Get value of entity

Parameters

text – full text

Returns

part of text

parse(text, as_html=True)[source]

Get entity value with markup

Parameters
  • text – original text

  • as_html – as html?

Returns

entity text with markup

MessageEntityType

class aiogram.types.message_entity.MessageEntityType[source]

Bases: Helper

List of entity types

Key

MENTION

Key

HASHTAG

Key

CASHTAG

Key

BOT_COMMAND

Key

URL

Key

EMAIL

Key

PHONE_NUMBER

Key

BOLD

Key

ITALIC

Key

UNDERLINE

Key

STRIKETHROUGH

Key

SPOILER

Key

CODE

Key

PRE

Key

TEXT_LINK

Key

TEXT_MENTION

Key

CUSTOM_EMOJI