tgbotxx 1.2.9.2
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) {
19 }
20 virtual ~InputMessageContent() = default;
21
23 std::string type;
24
25
26 [[nodiscard]] virtual nl::json toJson() const {
27 nl::json json = nl::json::object();
29 return json;
30 }
31
32 virtual void fromJson(const nl::json& json) {
33 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
34 }
35 };
36
37
42 type = "text";
43 }
47
49 std::string messageText;
50
52 std::string parseMode;
53
55 std::vector<Ptr<MessageEntity>> entities;
56
59
60 nl::json toJson() const override {
62 OBJECT_SERIALIZE_FIELD(json, "message_text", messageText);
65 OBJECT_SERIALIZE_FIELD(json, "disable_web_page_preview", disableWebPagePreview);
66 return json;
67 }
68
69 void fromJson(const nl::json& json) override {
71 OBJECT_DESERIALIZE_FIELD(json, "message_text", messageText, "", false);
72 OBJECT_DESERIALIZE_FIELD(json, "parse_mode", parseMode, "", true);
74 OBJECT_DESERIALIZE_FIELD(json, "disable_web_page_preview", disableWebPagePreview, false, true);
75 }
76 };
77
78
83 type = "location";
84 }
88
90 float latitude{};
91
93 float longitude{};
94
97
99 std::int32_t heading{};
100
102 std::int32_t proximityAlertRadius{};
103
104
105 nl::json toJson() const override {
109 OBJECT_SERIALIZE_FIELD(json, "horizontal_accuracy", horizontalAccuracy);
111 OBJECT_SERIALIZE_FIELD(json, "proximity_alert_radius", proximityAlertRadius);
112 return json;
113 }
114
115 void fromJson(const nl::json& json) override {
117 OBJECT_DESERIALIZE_FIELD(json, "latitude", latitude, 0.0f, false);
118 OBJECT_DESERIALIZE_FIELD(json, "longitude", longitude, 0.0f, false);
119 OBJECT_DESERIALIZE_FIELD(json, "horizontal_accuracy", horizontalAccuracy, 0.0f, true);
120 OBJECT_DESERIALIZE_FIELD(json, "heading", heading, 0, true);
121 OBJECT_DESERIALIZE_FIELD(json, "proximity_alert_radius", proximityAlertRadius, 0, true);
122 }
123 };
124
129 type = "venue";
130 }
134
136 float latitude{};
137
139 float longitude{};
140
142 std::string title;
143
145 std::string address;
146
148 std::string foursquareId;
149
151 std::string foursquareType;
152
154 std::string googlePlaceId;
155
157 std::string googlePlaceType;
158
159 nl::json toJson() const override {
165 OBJECT_SERIALIZE_FIELD(json, "foursquare_id", foursquareId);
166 OBJECT_SERIALIZE_FIELD(json, "foursquare_type", foursquareType);
167 OBJECT_SERIALIZE_FIELD(json, "google_place_id", googlePlaceId);
168 OBJECT_SERIALIZE_FIELD(json, "google_place_type", googlePlaceType);
169 return json;
170 }
171
172 void fromJson(const nl::json& json) override {
174 OBJECT_DESERIALIZE_FIELD(json, "latitude", latitude, 0.0f, false);
175 OBJECT_DESERIALIZE_FIELD(json, "longitude", longitude, 0.0f, false);
176 OBJECT_DESERIALIZE_FIELD(json, "title", title, "", false);
177 OBJECT_DESERIALIZE_FIELD(json, "address", address, "", false);
178 OBJECT_DESERIALIZE_FIELD(json, "foursquare_id", foursquareId, "", true);
179 OBJECT_DESERIALIZE_FIELD(json, "foursquare_type", foursquareType, "", true);
180 OBJECT_DESERIALIZE_FIELD(json, "google_place_id", googlePlaceId, "", true);
181 OBJECT_DESERIALIZE_FIELD(json, "google_place_type", googlePlaceType, "", true);
182 }
183 };
184
189 type = "contact";
190 }
194
196 std::string phoneNumber;
197
199 std::string firstName;
200
202 std::string lastName;
203
206 std::string vcard;
207
208 nl::json toJson() const override {
210 OBJECT_SERIALIZE_FIELD(json, "phone_number", phoneNumber);
211 OBJECT_SERIALIZE_FIELD(json, "first_name", firstName);
212 OBJECT_SERIALIZE_FIELD(json, "last_name", lastName);
214 return json;
215 }
216
217 void fromJson(const nl::json& json) override {
219 OBJECT_DESERIALIZE_FIELD(json, "phone_number", phoneNumber, "", false);
220 OBJECT_DESERIALIZE_FIELD(json, "first_name", firstName, "", false);
221 OBJECT_DESERIALIZE_FIELD(json, "last_name", lastName, "", true);
222 OBJECT_DESERIALIZE_FIELD(json, "vcard", vcard, "", true);
223 }
224 };
225
230 type = "invoice";
231 }
235
237 std::string title;
238
240 std::string description;
241
243 std::string payload;
244
246 std::string providerToken;
247
249 std::string currency;
250
252 std::vector<Ptr<LabeledPrice>> prices;
253
258 std::int32_t maxTipAmount{};
259
262 std::vector<std::int32_t> suggestedTipAmounts;
263
266 std::string providerData;
267
269 std::string photoUrl;
270
272 std::int64_t photoSize{};
273
275 std::int32_t photoWidth{};
276
278 std::int32_t photoHeight{};
279
281 bool needName{};
282
285
287 bool needEmail{};
288
291
294
297
300
301 nl::json toJson() const override {
304 OBJECT_SERIALIZE_FIELD(json, "description", description);
306 OBJECT_SERIALIZE_FIELD(json, "provider_token", providerToken);
309 OBJECT_SERIALIZE_FIELD(json, "max_tip_amount", maxTipAmount);
310 OBJECT_SERIALIZE_FIELD(json, "suggested_tip_amounts", suggestedTipAmounts);
311 OBJECT_SERIALIZE_FIELD(json, "provider_data", providerData);
312 OBJECT_SERIALIZE_FIELD(json, "photo_url", photoUrl);
313 OBJECT_SERIALIZE_FIELD(json, "photo_size", photoSize);
314 OBJECT_SERIALIZE_FIELD(json, "photo_width", photoWidth);
315 OBJECT_SERIALIZE_FIELD(json, "photo_height", photoHeight);
316 OBJECT_SERIALIZE_FIELD(json, "need_name", needName);
317 OBJECT_SERIALIZE_FIELD(json, "need_phone_number", needPhoneNumber);
318 OBJECT_SERIALIZE_FIELD(json, "need_email", needEmail);
319 OBJECT_SERIALIZE_FIELD(json, "need_shipping_address", needShippingAddress);
320 OBJECT_SERIALIZE_FIELD(json, "send_phone_number_to_provider", sendPhoneNumberToProvider);
321 OBJECT_SERIALIZE_FIELD(json, "send_email_to_provider", sendEmailToProvider);
322 OBJECT_SERIALIZE_FIELD(json, "is_flexible", isFlexible);
323 return json;
324 }
325
326 void fromJson(const nl::json& json) override {
328 OBJECT_DESERIALIZE_FIELD(json, "title", title, "", false);
329 OBJECT_DESERIALIZE_FIELD(json, "description", description, "", false);
330 OBJECT_DESERIALIZE_FIELD(json, "payload", payload, "", false);
331 OBJECT_DESERIALIZE_FIELD(json, "provider_token", providerToken, "", false);
332 OBJECT_DESERIALIZE_FIELD(json, "currency", currency, "", false);
334 OBJECT_DESERIALIZE_FIELD(json, "max_tip_amount", maxTipAmount, 0, true);
335 OBJECT_DESERIALIZE_FIELD(json, "suggested_tip_amounts", suggestedTipAmounts, std::vector<std::int32_t>(), true);
336 OBJECT_DESERIALIZE_FIELD(json, "provider_data", providerData, "", true);
337 OBJECT_DESERIALIZE_FIELD(json, "photo_url", photoUrl, "", true);
338 OBJECT_DESERIALIZE_FIELD(json, "photo_size", photoSize, 0, true);
339 OBJECT_DESERIALIZE_FIELD(json, "photo_width", photoWidth, 0, true);
340 OBJECT_DESERIALIZE_FIELD(json, "photo_height", photoHeight, 0, true);
341 OBJECT_DESERIALIZE_FIELD(json, "need_name", needName, false, true);
342 OBJECT_DESERIALIZE_FIELD(json, "need_phone_number", needPhoneNumber, false, true);
343 OBJECT_DESERIALIZE_FIELD(json, "need_email", needEmail, false, true);
344 OBJECT_DESERIALIZE_FIELD(json, "need_shipping_address", needShippingAddress, false, true);
345 OBJECT_DESERIALIZE_FIELD(json, "send_phone_number_to_provider", sendPhoneNumberToProvider, false, true);
346 OBJECT_DESERIALIZE_FIELD(json, "send_email_to_provider", sendEmailToProvider, false, true);
347 OBJECT_DESERIALIZE_FIELD(json, "is_flexible", isFlexible, false, true);
348 }
349 };
350}
#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
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
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....