tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
ReplyParameters.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
9 ReplyParameters() = default;
10 explicit ReplyParameters(const nl::json& json) {
11 fromJson(json);
12 }
13
15 std::int32_t messageId{};
16
19 std::variant<std::int64_t, std::string> chatId; // std::monostate
20
24
28 std::string quote;
29
32 std::string quoteParseMode;
33
35 std::vector<Ptr<MessageEntity>> quoteEntities;
36
38 std::int32_t quotePosition{};
39
41 std::int32_t checklistTaskId{};
42
43
46 nl::json toJson() const {
47 nl::json json = nl::json::object();
48 OBJECT_SERIALIZE_FIELD(json, "message_id", messageId);
49 if (std::holds_alternative<std::int64_t>(chatId)) {
50 OBJECT_SERIALIZE_FIELD(json, "chat_id", std::get<std::int64_t>(chatId));
51 } else if (std::holds_alternative<std::string>(chatId)) {
52 OBJECT_SERIALIZE_FIELD(json, "chat_id", std::get<std::string>(chatId));
53 }
54 OBJECT_SERIALIZE_FIELD(json, "allow_sending_without_reply", allowSendingWithoutReply);
55 OBJECT_SERIALIZE_FIELD(json, "quote", quote);
56 OBJECT_SERIALIZE_FIELD(json, "quote_parse_mode", quoteParseMode);
57 OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, "quote_entities", quoteEntities);
58 OBJECT_SERIALIZE_FIELD(json, "quote_position", quotePosition);
59 OBJECT_SERIALIZE_FIELD(json, "checklist_task_id", checklistTaskId);
60 return json;
61 }
62
64 void fromJson(const nl::json& json) {
65 OBJECT_DESERIALIZE_FIELD(json, "message_id", messageId, 0, false);
66 if (json["chat_id"].is_string()) chatId = json["chat_id"].get<std::string>();
67 else chatId = json["chat_id"].get<std::int64_t>();
68 OBJECT_DESERIALIZE_FIELD(json, "allow_sending_without_reply", allowSendingWithoutReply, false, true);
69 OBJECT_DESERIALIZE_FIELD(json, "quote", quote, "", true);
70 OBJECT_DESERIALIZE_FIELD(json, "quote_parse_mode", quoteParseMode, "", true);
71 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "quote_entities", quoteEntities, true);
72 OBJECT_DESERIALIZE_FIELD(json, "quote_position", quotePosition, 0, true);
73 OBJECT_DESERIALIZE_FIELD(json, "checklist_task_id", checklistTaskId, 0, true);
74 }
75 };
76}
#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
Describes reply parameters for the message that is being sent. https://core.telegram....
nl::json toJson() const
Serializes this object to JSON.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
ReplyParameters(const nl::json &json)
std::vector< Ptr< MessageEntity > > quoteEntities
Optional. A JSON-serialized list of special entities that appear in the quote. It can be specified in...
std::int32_t checklistTaskId
Optional. Identifier of the specific checklist task to be replied to.
std::string quote
Optional. Quoted part of the message to be replied to; 0-1024 characters after entities parsing....
std::int32_t messageId
Identifier of the message that will be replied to in the current chat, or in the chat chat_id if it i...
std::string quoteParseMode
Optional. Mode for parsing entities in the quote. See formatting options for more details.
std::variant< std::int64_t, std::string > chatId
Optional. If the message to be replied to is from a different chat, unique identifier for the chat or...
std::int32_t quotePosition
Optional. Position of the quote in the original message in UTF-16 code units.
bool allowSendingWithoutReply
Optional. Pass True if the message should be sent even if the specified message to be replied to is n...