tgbotxx  1.1.6.9
Telegram Bot C++ Library
tgbotxx::MessageEntity Struct Reference

This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. https://core.telegram.org/bots/api#messageentity. More...

#include <MessageEntity.hpp>

Public Types

enum class  Type : std::uint8_t {
  Mention = 0 , Hashtag , Cashtag , BotCommand ,
  Url , Email , PhoneNumber , Bold ,
  Italic , Underline , Strikethrough , Spoiler ,
  Code , Pre , TextLink , TextMention ,
  CustomEmoji
}
 Enum of possible types of MessageEntity. More...
 

Public Member Functions

 MessageEntity ()=default
 
 MessageEntity (const nl::json &json)
 
nl::json toJson () const
 Serializes this object to JSON. More...
 
void fromJson (const nl::json &json)
 Deserializes this object from JSON. More...
 

Static Public Member Functions

static constexpr Type Str2Type (const std::string &str)
 

Public Attributes

Type type {}
 Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-no.nosp@m.t-re.nosp@m.ply@t.nosp@m.eleg.nosp@m.ram.o.nosp@m.rg), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), “custom_emoji” (for inline custom emoji stickers) More...
 
std::int32_t offset {}
 Offset in UTF-16 code units to the start of the entity. More...
 
std::int32_t length {}
 Length of the entity in UTF-16 code units. More...
 
std::string url
 Optional. For “text_link” only, URL that will be opened after user taps on the text. More...
 
Ptr< Useruser
 Optional. For “text_mention” only, the mentioned user. More...
 
std::string language
 Optional. For “pre” only, the programming language of the entity text. More...
 
std::string customEmojiId
 Optional. For “custom_emoji” only, unique identifier of the custom emoji. Use Api::getCustomEmojiStickers to get full information about the sticker. More...
 

Static Public Attributes

static constexpr const char * Type2Str []
 

Detailed Description

This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. https://core.telegram.org/bots/api#messageentity.

Definition at line 8 of file MessageEntity.hpp.

Member Enumeration Documentation

◆ Type

enum tgbotxx::MessageEntity::Type : std::uint8_t
strong

Enum of possible types of MessageEntity.

Enumerator
Mention 

“mention” (@username)

Hashtag 

“hashtag” (#hashtag)

Cashtag 

“cashtag” ($USD)

BotCommand 

“bot_command” (/start@jobs_bot)

Url 

“url” (https://telegram.org)

Email 

“email” (do-no.nosp@m.t-re.nosp@m.ply@t.nosp@m.eleg.nosp@m.ram.o.nosp@m.rg)

PhoneNumber 

“phone_number” (+1-212-555-0123)

Bold 

“bold” (bold text)

Italic 

“italic” (italic text)

Underline 

“underline” (underlined text)

Strikethrough 

“strikethrough” (strikethrough text)

Spoiler 

“spoiler” (spoiler message)

Code 

“code” (monowidth string)

Pre 

“pre” (monowidth block)

TextLink 

“text_link” (for clickable text URLs)

TextMention 

“text_mention” (for users without usernames)

CustomEmoji 

“custom_emoji” (for inline custom emoji stickers)

Definition at line 15 of file MessageEntity.hpp.

Constructor & Destructor Documentation

◆ MessageEntity() [1/2]

tgbotxx::MessageEntity::MessageEntity ( )
default

◆ MessageEntity() [2/2]

tgbotxx::MessageEntity::MessageEntity ( const nl::json &  json)
inlineexplicit

Definition at line 10 of file MessageEntity.hpp.

Member Function Documentation

◆ fromJson()

void tgbotxx::MessageEntity::fromJson ( const nl::json &  json)
inline

Deserializes this object from JSON.

Definition at line 123 of file MessageEntity.hpp.

◆ Str2Type()

static constexpr Type tgbotxx::MessageEntity::Str2Type ( const std::string &  str)
inlinestaticconstexpr

Definition at line 70 of file MessageEntity.hpp.

◆ toJson()

nl::json tgbotxx::MessageEntity::toJson ( ) const
inline

Serializes this object to JSON.

Returns
JSON representation of this object

Definition at line 110 of file MessageEntity.hpp.

Member Data Documentation

◆ customEmojiId

std::string tgbotxx::MessageEntity::customEmojiId

Optional. For “custom_emoji” only, unique identifier of the custom emoji. Use Api::getCustomEmojiStickers to get full information about the sticker.

Definition at line 106 of file MessageEntity.hpp.

◆ language

std::string tgbotxx::MessageEntity::language

Optional. For “pre” only, the programming language of the entity text.

Definition at line 102 of file MessageEntity.hpp.

◆ length

std::int32_t tgbotxx::MessageEntity::length {}

Length of the entity in UTF-16 code units.

Definition at line 93 of file MessageEntity.hpp.

◆ offset

std::int32_t tgbotxx::MessageEntity::offset {}

Offset in UTF-16 code units to the start of the entity.

Definition at line 90 of file MessageEntity.hpp.

◆ type

Type tgbotxx::MessageEntity::type {}

Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-no.nosp@m.t-re.nosp@m.ply@t.nosp@m.eleg.nosp@m.ram.o.nosp@m.rg), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), “custom_emoji” (for inline custom emoji stickers)

Definition at line 87 of file MessageEntity.hpp.

◆ Type2Str

constexpr const char* tgbotxx::MessageEntity::Type2Str[]
inlinestaticconstexpr
Initial value:
= {
"mention",
"hashtag",
"cashtag",
"bot_command",
"url",
"email",
"phone_number",
"bold",
"italic",
"underline",
"strikethrough",
"spoiler",
"code",
"pre",
"text_link",
"text_mention",
"custom_emoji"}

Definition at line 51 of file MessageEntity.hpp.

◆ url

std::string tgbotxx::MessageEntity::url

Optional. For “text_link” only, URL that will be opened after user taps on the text.

Definition at line 96 of file MessageEntity.hpp.

◆ user

Ptr<User> tgbotxx::MessageEntity::user

Optional. For “text_mention” only, the mentioned user.

Definition at line 99 of file MessageEntity.hpp.


The documentation for this struct was generated from the following file: