tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
InputMessageContent.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
17 explicit InputMessageContent(const nl::json& json) {
18 _fromJson(json);
19 }
20 virtual ~InputMessageContent() = default;
21
23 std::string type;
24
25
26 virtual nl::json toJson() const {
27 nl::json json = nl::json::object();
28 OBJECT_SERIALIZE_FIELD(json, "type", type);
29 return json;
30 }
31
32 virtual void fromJson(const nl::json& json) {
33 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
34 }
35
36 private:
37 void _fromJson(const nl::json& json) {
38 fromJson(json);
39 }
40 };
41
42
49 explicit InputTextMessageContent(const nl::json& json) : InputMessageContent(json) {
51 }
52
54 std::string messageText;
55
57 std::string parseMode;
58
60 std::vector<Ptr<MessageEntity>> entities;
61
64
65 nl::json toJson() const override {
66 nl::json json = InputMessageContent::toJson();
67 OBJECT_SERIALIZE_FIELD(json, "message_text", messageText);
68 OBJECT_SERIALIZE_FIELD(json, "parse_mode", parseMode);
70 OBJECT_SERIALIZE_FIELD(json, "disable_web_page_preview", disableWebPagePreview);
71 return json;
72 }
73
74 void fromJson(const nl::json& json) override {
76 OBJECT_DESERIALIZE_FIELD(json, "message_text", messageText, "", false);
77 OBJECT_DESERIALIZE_FIELD(json, "parse_mode", parseMode, "", true);
78 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "entities", entities, true);
79 OBJECT_DESERIALIZE_FIELD(json, "disable_web_page_preview", disableWebPagePreview, false, true);
80 }
81 };
82
83
90 explicit InputLocationMessageContent(const nl::json& json) : InputMessageContent(json) {
91 InputMessageContent::type = "location";
92 }
93
95 float latitude{};
96
98 float longitude{};
99
102
104 std::int32_t heading{};
105
107 std::int32_t proximityAlertRadius{};
108
109
110 nl::json toJson() const override {
111 nl::json json = InputMessageContent::toJson();
112 OBJECT_SERIALIZE_FIELD(json, "latitude", latitude);
113 OBJECT_SERIALIZE_FIELD(json, "longitude", longitude);
114 OBJECT_SERIALIZE_FIELD(json, "horizontal_accuracy", horizontalAccuracy);
115 OBJECT_SERIALIZE_FIELD(json, "heading", heading);
116 OBJECT_SERIALIZE_FIELD(json, "proximity_alert_radius", proximityAlertRadius);
117 return json;
118 }
119
120 void fromJson(const nl::json& json) override {
122 OBJECT_DESERIALIZE_FIELD(json, "latitude", latitude, 0.0f, false);
123 OBJECT_DESERIALIZE_FIELD(json, "longitude", longitude, 0.0f, false);
124 OBJECT_DESERIALIZE_FIELD(json, "horizontal_accuracy", horizontalAccuracy, 0.0f, true);
125 OBJECT_DESERIALIZE_FIELD(json, "heading", heading, 0, true);
126 OBJECT_DESERIALIZE_FIELD(json, "proximity_alert_radius", proximityAlertRadius, 0, true);
127 }
128 };
129
136 explicit InputVenueMessageContent(const nl::json& json) : InputMessageContent(json) {
138 }
139
141 float latitude{};
142
144 float longitude{};
145
147 std::string title;
148
150 std::string address;
151
153 std::string foursquareId;
154
156 std::string foursquareType;
157
159 std::string googlePlaceId;
160
162 std::string googlePlaceType;
163
164 nl::json toJson() const override {
165 nl::json json = InputMessageContent::toJson();
166 OBJECT_SERIALIZE_FIELD(json, "latitude", latitude);
167 OBJECT_SERIALIZE_FIELD(json, "longitude", longitude);
168 OBJECT_SERIALIZE_FIELD(json, "title", title);
169 OBJECT_SERIALIZE_FIELD(json, "address", address);
170 OBJECT_SERIALIZE_FIELD(json, "foursquare_id", foursquareId);
171 OBJECT_SERIALIZE_FIELD(json, "foursquare_type", foursquareType);
172 OBJECT_SERIALIZE_FIELD(json, "google_place_id", googlePlaceId);
173 OBJECT_SERIALIZE_FIELD(json, "google_place_type", googlePlaceType);
174 return json;
175 }
176
177 void fromJson(const nl::json& json) override {
179 OBJECT_DESERIALIZE_FIELD(json, "latitude", latitude, 0.0f, false);
180 OBJECT_DESERIALIZE_FIELD(json, "longitude", longitude, 0.0f, false);
181 OBJECT_DESERIALIZE_FIELD(json, "title", title, "", false);
182 OBJECT_DESERIALIZE_FIELD(json, "address", address, "", false);
183 OBJECT_DESERIALIZE_FIELD(json, "foursquare_id", foursquareId, "", true);
184 OBJECT_DESERIALIZE_FIELD(json, "foursquare_type", foursquareType, "", true);
185 OBJECT_DESERIALIZE_FIELD(json, "google_place_id", googlePlaceId, "", true);
186 OBJECT_DESERIALIZE_FIELD(json, "google_place_type", googlePlaceType, "", true);
187 }
188 };
189
196 explicit InputContactMessageContent(const nl::json& json) : InputMessageContent(json) {
197 InputMessageContent::type = "contact";
198 }
199
201 std::string phoneNumber;
202
204 std::string firstName;
205
207 std::string lastName;
208
211 std::string vcard;
212
213 nl::json toJson() const override {
214 nl::json json = InputMessageContent::toJson();
215 OBJECT_SERIALIZE_FIELD(json, "phone_number", phoneNumber);
216 OBJECT_SERIALIZE_FIELD(json, "first_name", firstName);
217 OBJECT_SERIALIZE_FIELD(json, "last_name", lastName);
218 OBJECT_SERIALIZE_FIELD(json, "vcard", vcard);
219 return json;
220 }
221
222 void fromJson(const nl::json& json) override {
224 OBJECT_DESERIALIZE_FIELD(json, "phone_number", phoneNumber, "", false);
225 OBJECT_DESERIALIZE_FIELD(json, "first_name", firstName, "", false);
226 OBJECT_DESERIALIZE_FIELD(json, "last_name", lastName, "", true);
227 OBJECT_DESERIALIZE_FIELD(json, "vcard", vcard, "", true);
228 }
229 };
230
237 explicit InputInvoiceMessageContent(const nl::json& json) : InputMessageContent(json) {
238 InputMessageContent::type = "invoice";
239 }
240
242 std::string title;
243
245 std::string description;
246
248 std::string payload;
249
251 std::string providerToken;
252
254 std::string currency;
255
257 std::vector<Ptr<LabeledPrice>> prices;
258
263 std::int32_t maxTipAmount{};
264
267 std::vector<std::int32_t> suggestedTipAmounts;
268
271 std::string providerData;
272
274 std::string photoUrl;
275
277 std::int64_t photoSize{};
278
280 std::int32_t photoWidth{};
281
283 std::int32_t photoHeight{};
284
286 bool needName{};
287
290
292 bool needEmail{};
293
296
299
302
305
306 nl::json toJson() const override {
307 nl::json json = InputMessageContent::toJson();
308 OBJECT_SERIALIZE_FIELD(json, "title", title);
309 OBJECT_SERIALIZE_FIELD(json, "description", description);
310 OBJECT_SERIALIZE_FIELD(json, "payload", payload);
311 OBJECT_SERIALIZE_FIELD(json, "provider_token", providerToken);
312 OBJECT_SERIALIZE_FIELD(json, "currency", currency);
314 OBJECT_SERIALIZE_FIELD(json, "max_tip_amount", maxTipAmount);
315 OBJECT_SERIALIZE_FIELD(json, "suggested_tip_amounts", suggestedTipAmounts);
316 OBJECT_SERIALIZE_FIELD(json, "provider_data", providerData);
317 OBJECT_SERIALIZE_FIELD(json, "photo_url", photoUrl);
318 OBJECT_SERIALIZE_FIELD(json, "photo_size", photoSize);
319 OBJECT_SERIALIZE_FIELD(json, "photo_width", photoWidth);
320 OBJECT_SERIALIZE_FIELD(json, "photo_height", photoHeight);
321 OBJECT_SERIALIZE_FIELD(json, "need_name", needName);
322 OBJECT_SERIALIZE_FIELD(json, "need_phone_number", needPhoneNumber);
323 OBJECT_SERIALIZE_FIELD(json, "need_email", needEmail);
324 OBJECT_SERIALIZE_FIELD(json, "need_shipping_address", needShippingAddress);
325 OBJECT_SERIALIZE_FIELD(json, "send_phone_number_to_provider", sendPhoneNumberToProvider);
326 OBJECT_SERIALIZE_FIELD(json, "send_email_to_provider", sendEmailToProvider);
327 OBJECT_SERIALIZE_FIELD(json, "is_flexible", isFlexible);
328 return json;
329 }
330
331 void fromJson(const nl::json& json) override {
333 OBJECT_DESERIALIZE_FIELD(json, "title", title, "", false);
334 OBJECT_DESERIALIZE_FIELD(json, "description", description, "", false);
335 OBJECT_DESERIALIZE_FIELD(json, "payload", payload, "", false);
336 OBJECT_DESERIALIZE_FIELD(json, "provider_token", providerToken, "", false);
337 OBJECT_DESERIALIZE_FIELD(json, "currency", currency, "", false);
338 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "prices", prices, false);
339 OBJECT_DESERIALIZE_FIELD(json, "max_tip_amount", maxTipAmount, 0, true);
340 OBJECT_DESERIALIZE_FIELD(json, "suggested_tip_amounts", suggestedTipAmounts, std::vector<std::int32_t>(), true);
341 OBJECT_DESERIALIZE_FIELD(json, "provider_data", providerData, "", true);
342 OBJECT_DESERIALIZE_FIELD(json, "photo_url", photoUrl, "", true);
343 OBJECT_DESERIALIZE_FIELD(json, "photo_size", photoSize, 0, true);
344 OBJECT_DESERIALIZE_FIELD(json, "photo_width", photoWidth, 0, true);
345 OBJECT_DESERIALIZE_FIELD(json, "photo_height", photoHeight, 0, true);
346 OBJECT_DESERIALIZE_FIELD(json, "need_name", needName, false, true);
347 OBJECT_DESERIALIZE_FIELD(json, "need_phone_number", needPhoneNumber, false, true);
348 OBJECT_DESERIALIZE_FIELD(json, "need_email", needEmail, false, true);
349 OBJECT_DESERIALIZE_FIELD(json, "need_shipping_address", needShippingAddress, false, true);
350 OBJECT_DESERIALIZE_FIELD(json, "send_phone_number_to_provider", sendPhoneNumberToProvider, false, true);
351 OBJECT_DESERIALIZE_FIELD(json, "send_email_to_provider", sendEmailToProvider, false, true);
352 OBJECT_DESERIALIZE_FIELD(json, "is_flexible", isFlexible, false, true);
353 }
354 };
355}
#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
Represents the content of a contact message to be sent as the result of an inline query....
std::string lastName
Optional. Contact's last name.
std::string firstName
Contact's first name.
std::string phoneNumber
Contact's phone number.
void fromJson(const nl::json &json) override
std::string vcard
Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes https://en....
Represents the content of a invoice message to be sent as the result of an inline query....
std::string payload
Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your intern...
bool isFlexible
Optional. Pass True if the final price depends on the shipping method.
bool sendEmailToProvider
Optional. Pass True if the user's email address should be sent to provider.
bool sendPhoneNumberToProvider
Optional. Pass True if the user's phone number should be sent to provider.
bool needName
Optional. Pass True if you require the user's full name to complete the order.
std::string currency
Three-letter ISO 4217 currency code, see more on currencies
bool needPhoneNumber
Optional. Pass True if you require the user's phone number to complete the order.
std::int64_t photoSize
Optional. Photo size in bytes.
bool needShippingAddress
Optional. Pass True if you require the user's shipping address to complete the order.
std::int32_t photoWidth
Optional. Photo width.
std::string providerData
Optional. A JSON-serialized object for data about the invoice, which will be shared with the payment ...
bool needEmail
Optional. Pass True if you require the user's email address to complete the order.
std::string photoUrl
Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image ...
void fromJson(const nl::json &json) override
std::int32_t photoHeight
Optional. Photo height.
std::vector< Ptr< LabeledPrice > > prices
Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount,...
std::int32_t maxTipAmount
Optional. The maximum accepted amount for tips in the smallest units of the currency (integer,...
std::string title
Product name, 1-32 characters.
std::string description
Product description, 1-255 characters.
std::string providerToken
Payment provider token, obtained via @BotFather.
std::vector< std::int32_t > suggestedTipAmounts
Optional. A JSON-serialized array of suggested amounts of tip in the smallest units of the currency (...
Represents the content of a location message to be sent as the result of an inline query....
float horizontalAccuracy
Optional. The radius of uncertainty for the location, measured in meters; 0-1500.
std::int32_t proximityAlertRadius
Optional. For live locations, a maximum distance for proximity alerts about approaching another chat ...
float latitude
Latitude of the location in degrees.
float longitude
Longitude of the location in degrees.
std::int32_t heading
Optional. For live locations, a direction in which the user is moving, in degrees....
void fromJson(const nl::json &json) override
Base class of all inline query results This object represents the content of a message to be sent as ...
virtual void fromJson(const nl::json &json)
virtual ~InputMessageContent()=default
InputMessageContent(const nl::json &json)
std::string type
Type of this content.
virtual nl::json toJson() const
Represents the content of a text message to be sent as the result of an inline query....
InputTextMessageContent(const nl::json &json)
bool disableWebPagePreview
Optional. Disables link previews for links in the sent message.
std::string messageText
Text of the message to be sent, 1-4096 characters.
std::vector< Ptr< MessageEntity > > entities
Optional. List of special entities that appear in message text, which can be specified instead of par...
void fromJson(const nl::json &json) override
std::string parseMode
Optional. Mode for parsing entities in the message text. See formatting options for more details.
Represents the content of a venue message to be sent as the result of an inline query....
void fromJson(const nl::json &json) override
float latitude
Latitude of the venue in degrees.
std::string googlePlaceId
Optional. Google Places identifier of the venue.
std::string address
Address of the venue.
std::string title
Name of the venue.
float longitude
Longitude of the venue in degrees.
std::string foursquareId
Optional. Foursquare identifier of the venue, if known.
std::string foursquareType
Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”,...
std::string googlePlaceType
Optional. Google Places type of the venue. (See supported types.) https://developers....