tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
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 ,
  Blockquote , ExpandableBlockquote , 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.
 
void fromJson (const nl::json &json)
 Deserializes this object from JSON.
 

Static Public Member Functions

static std::optional< std::string > TypeToString (const Type type) noexcept
 Converts enum Type to a string.
 
static std::optional< TypeStringToType (const std::string &str) noexcept
 Converts string to an enum Type.
 

Public Attributes

Type type {}
 Type of the entity. Type of the entity. Currently, can be: “mention” (@username), “hashtag” (#hashtag or #hashtag@chatusername), “cashtag” ($USD or $USD@chatusername), “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), “blockquote” (block quotation), “expandable_blockquote” (collapsed-by-default block quotation), “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)
 
std::int32_t offset {}
 Offset in UTF-16 code units to the start of the entity.
 
std::int32_t length {}
 Length of the entity in UTF-16 code units.
 
std::string url
 Optional. For “text_link” only, URL that will be opened after user taps on the text.
 
Ptr< Useruser
 Optional. For “text_mention” only, the mentioned user.
 
std::string language
 Optional. For “pre” only, the programming language of the entity text.
 
std::string customEmojiId
 Optional. For “custom_emoji” only, unique identifier of the custom emoji. Use Api::getCustomEmojiStickers to get full information about the sticker.
 

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 class tgbotxx::MessageEntity::Type : std::uint8_t
strong

Enum of possible types of MessageEntity.

Enumerator
Mention 

“mention” (@username),

Hashtag 

“hashtag” (#hashtag or #hashtag@chatusername),

Cashtag 

“cashtag” ($USD or $USD@chatusername),

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),

Blockquote 

“blockquote” (block quotation),

ExpandableBlockquote 

“expandable_blockquote” (collapsed-by-default block quotation),

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 159 of file MessageEntity.hpp.

◆ StringToType()

static std::optional< Type > tgbotxx::MessageEntity::StringToType ( const std::string &  str)
inlinestaticnoexcept

Converts string to an enum Type.

Definition at line 79 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 146 of file MessageEntity.hpp.

◆ TypeToString()

static std::optional< std::string > tgbotxx::MessageEntity::TypeToString ( const Type  type)
inlinestaticnoexcept

Converts enum Type to a string.

Definition at line 56 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 142 of file MessageEntity.hpp.

◆ language

std::string tgbotxx::MessageEntity::language

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

Definition at line 138 of file MessageEntity.hpp.

◆ length

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

Length of the entity in UTF-16 code units.

Definition at line 129 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 126 of file MessageEntity.hpp.

◆ type

Type tgbotxx::MessageEntity::type {}

Type of the entity. Type of the entity. Currently, can be: “mention” (@username), “hashtag” (#hashtag or #hashtag@chatusername), “cashtag” ($USD or $USD@chatusername), “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), “blockquote” (block quotation), “expandable_blockquote” (collapsed-by-default block quotation), “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 123 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 132 of file MessageEntity.hpp.

◆ user

Ptr<User> tgbotxx::MessageEntity::user

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

Definition at line 135 of file MessageEntity.hpp.


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