tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
TextQuote.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
8 struct TextQuote {
9 TextQuote() = default;
10 explicit TextQuote(const nl::json& json) {
11 fromJson(json);
12 }
13
15 std::string text;
16
19 std::vector<Ptr<MessageEntity>> entities;
20
22 std::int32_t position{};
23
25 bool isManual{};
26
29 nl::json toJson() const {
30 nl::json json = nl::json::object();
31 OBJECT_SERIALIZE_FIELD(json, "text", text);
33 OBJECT_SERIALIZE_FIELD(json, "position", position);
34 OBJECT_SERIALIZE_FIELD(json, "is_manual", isManual);
35 return json;
36 }
37
39 void fromJson(const nl::json& json) {
40 OBJECT_DESERIALIZE_FIELD(json, "text", text, "", false);
41 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "entities", entities, true);
42 OBJECT_DESERIALIZE_FIELD(json, "position", position, 0, false);
43 OBJECT_DESERIALIZE_FIELD(json, "is_manual", isManual, false, true);
44 }
45 };
46}
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition Object.hpp:27
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:46
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition Object.hpp:89
This object contains information about the quoted part of a message that is replied to by the given m...
Definition TextQuote.hpp:8
std::vector< Ptr< MessageEntity > > entities
Optional. Special entities that appear in the quote. Currently, only bold, italic,...
Definition TextQuote.hpp:19
nl::json toJson() const
Serializes this object to JSON.
Definition TextQuote.hpp:29
std::int32_t position
Approximate quote position in the original message in UTF-16 code units as specified by the sender.
Definition TextQuote.hpp:22
TextQuote(const nl::json &json)
Definition TextQuote.hpp:10
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition TextQuote.hpp:39
bool isManual
Optional. True, if the quote was chosen manually by the message sender. Otherwise,...
Definition TextQuote.hpp:25
std::string text
Text of the quoted part of a message that is replied to by the given message.
Definition TextQuote.hpp:15