15 enum class Type : std::uint8_t {
51 inline static constexpr
const char *
Type2Str[] = {
74 return static_cast<Type>(i);
77 throw Exception(
"Could not convert MessageEntity type string \"" + str +
"\" to enum Type");
111 nl::json json = nl::json::object();
112 json[
"type"] =
Type2Str[
static_cast<std::size_t
>(
type)];
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
This object represents one special entity in a text message. For example, hashtags,...
std::int32_t length
Length of the entity in UTF-16 code units.
nl::json toJson() const
Serializes this object to JSON.
std::string url
Optional. For “text_link” only, URL that will be opened after user taps on the text.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Type
Enum of possible types of MessageEntity.
@ Url
“url” (https://telegram.org)
@ Italic
“italic” (italic text)
@ TextMention
“text_mention” (for users without usernames)
@ Mention
“mention” (@username)
@ BotCommand
“bot_command” (/start@jobs_bot)
@ PhoneNumber
“phone_number” (+1-212-555-0123)
@ Hashtag
“hashtag” (#hashtag)
@ TextLink
“text_link” (for clickable text URLs)
@ Underline
“underline” (underlined text)
@ Cashtag
“cashtag” ($USD)
@ Strikethrough
“strikethrough” (strikethrough text)
@ Code
“code” (monowidth string)
@ Email
“email” (do-not-reply@telegram.org)
@ CustomEmoji
“custom_emoji” (for inline custom emoji stickers)
@ Spoiler
“spoiler” (spoiler message)
@ Pre
“pre” (monowidth block)
Type type
Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag),...
static constexpr const char * Type2Str[]
MessageEntity(const nl::json &json)
std::string language
Optional. For “pre” only, the programming language of the entity text.
std::int32_t offset
Offset in UTF-16 code units to the start of the entity.
std::string customEmojiId
Optional. For “custom_emoji” only, unique identifier of the custom emoji. Use Api::getCustomEmojiStic...
static constexpr Type Str2Type(const std::string &str)
Ptr< User > user
Optional. For “text_mention” only, the mentioned user.