tgbotxx  1.1.6.9
Telegram Bot C++ Library
ReplyParameters.hpp
Go to the documentation of this file.
1 #pragma once
4 
5 namespace tgbotxx {
8  struct ReplyParameters {
9  ReplyParameters() = default;
10  explicit ReplyParameters(const nl::json& json) {
11  fromJson(json);
12  }
13 
15  std::int32_t messageId{};
16 
19  std::int64_t chatId{};
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 
40 
43  nl::json toJson() const {
44  nl::json json = nl::json::object();
45  OBJECT_SERIALIZE_FIELD(json, "message_id", messageId);
46  OBJECT_SERIALIZE_FIELD(json, "chat_id", chatId);
47  OBJECT_SERIALIZE_FIELD(json, "allow_sending_without_reply", allowSendingWithoutReply);
48  OBJECT_SERIALIZE_FIELD(json, "quote", quote);
49  OBJECT_SERIALIZE_FIELD(json, "quote_parse_mode", quoteParseMode);
50  OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, "quote_entities", quoteEntities);
51  OBJECT_SERIALIZE_FIELD(json, "quote_position", quotePosition);
52  return json;
53  }
54 
56  void fromJson(const nl::json& json) {
57  OBJECT_DESERIALIZE_FIELD(json, "message_id", messageId, 0, false);
58  OBJECT_DESERIALIZE_FIELD(json, "chat_id", chatId, 0, true);
59  OBJECT_DESERIALIZE_FIELD(json, "allow_sending_without_reply", allowSendingWithoutReply, false, true);
60  OBJECT_DESERIALIZE_FIELD(json, "quote", quote, "", true);
61  OBJECT_DESERIALIZE_FIELD(json, "quote_parse_mode", quoteParseMode, "", true);
62  OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "quote_entities", quoteEntities, true);
63  OBJECT_DESERIALIZE_FIELD(json, "quote_position", quotePosition, 0, true);
64  }
65  };
66 }
#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:44
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition: Object.hpp:87
Definition: Api.hpp:14
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::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::int64_t 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...