diff --git a/include/tgbot/types/CallbackQuery.h b/include/tgbot/types/CallbackQuery.h index 58e02b35..6d994f42 100644 --- a/include/tgbot/types/CallbackQuery.h +++ b/include/tgbot/types/CallbackQuery.h @@ -5,6 +5,7 @@ #include "tgbot/types/Message.h" #include +#include #include namespace TgBot { @@ -35,7 +36,7 @@ class CallbackQuery { /** * @brief Optional. Identifier of the message sent via the bot in inline mode, that originated the query. */ - std::string inlineMessageId; + std::optional inlineMessageId; /** * @brief Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. diff --git a/include/tgbot/types/InputInvoiceMessageContent.h b/include/tgbot/types/InputInvoiceMessageContent.h index 17721c87..aba5ab13 100644 --- a/include/tgbot/types/InputInvoiceMessageContent.h +++ b/include/tgbot/types/InputInvoiceMessageContent.h @@ -71,7 +71,7 @@ class InputInvoiceMessageContent : public InputMessageContent { * At most 4 suggested tip amounts can be specified. * The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed maxTipAmount. */ - std::vector suggestedTipAmounts; + std::optional> suggestedTipAmounts; /** * @brief Optional. A JSON-serialized object for data about the invoice, which will be shared with the payment provider. diff --git a/include/tgbot/types/InputSticker.h b/include/tgbot/types/InputSticker.h index a5b5a313..6987dd01 100644 --- a/include/tgbot/types/InputSticker.h +++ b/include/tgbot/types/InputSticker.h @@ -4,6 +4,7 @@ #include "tgbot/types/MaskPosition.h" #include +#include #include #include @@ -50,7 +51,7 @@ class InputSticker { * * For “regular” and “custom_emoji” stickers only. */ - std::vector keywords; + std::optional> keywords; }; } diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h index 66f29561..01a6196c 100644 --- a/include/tgbot/types/Message.h +++ b/include/tgbot/types/Message.h @@ -254,7 +254,7 @@ class Message { /** * @brief Optional. Caption for the animation, audio, document, photo, video or voice */ - std::string caption; + std::optional caption; /** * @brief Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption diff --git a/include/tgbot/types/WebhookInfo.h b/include/tgbot/types/WebhookInfo.h index a55ed088..7e475eb8 100644 --- a/include/tgbot/types/WebhookInfo.h +++ b/include/tgbot/types/WebhookInfo.h @@ -61,7 +61,7 @@ class WebhookInfo { /** * @brief Optional. A list of update types the bot is subscribed to. Defaults to all update types except chatMember */ - std::vector allowedUpdates; + std::optional> allowedUpdates; }; } diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index e6039c87..6fbf8040 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -375,8 +375,10 @@ DECLARE_PARSER_FROM_JSON(WebhookInfo) { parse(data, "last_synchronization_error_date", &result->lastSynchronizationErrorDate); parse(data, "max_connections", &result->maxConnections); - result->allowedUpdates = - parsePrimitiveArray(data, "allowed_updates"); + if (data.contains("allowed_updates") && !data["allowed_updates"].is_null()) { + result->allowedUpdates = + parsePrimitiveArray(data, "allowed_updates"); + } return result; } @@ -393,7 +395,7 @@ DECLARE_PARSER_TO_JSON(WebhookInfo) { object->lastSynchronizationErrorDate); json.put("max_connections", object->maxConnections); - json.put("allowed_updates", put(object->allowedUpdates)); + json.put("allowed_updates", object->allowedUpdates); } return json; } @@ -3489,7 +3491,9 @@ DECLARE_PARSER_FROM_JSON(InputSticker) { parse(data, "format", &result->format); result->emojiList = parsePrimitiveArray(data, "emoji_list"); result->maskPosition = parse(data, "mask_position"); - result->keywords = parsePrimitiveArray(data, "keywords"); + if (data.contains("keywords") && !data["keywords"].is_null()) { + result->keywords = parsePrimitiveArray(data, "keywords"); + } return result; } @@ -3503,7 +3507,7 @@ DECLARE_PARSER_TO_JSON(InputSticker) { ptree.put("format", object->format); ptree.put("emoji_list", put(object->emojiList)); ptree.put("mask_position", put(object->maskPosition)); - ptree.put("keywords", put(object->keywords)); + ptree.put("keywords", object->keywords); return ptree; } @@ -4343,8 +4347,10 @@ DECLARE_PARSER_FROM_JSON(InputInvoiceMessageContent) { parse(data, "currency", &result->currency); result->prices = parseArray(data, "prices"); parse(data, "max_tip_amount", &result->maxTipAmount); - result->suggestedTipAmounts = - parsePrimitiveArray(data, "suggested_tip_amounts"); + if (data.contains("suggested_tip_amounts") && !data["suggested_tip_amounts"].is_null()) { + result->suggestedTipAmounts = + parsePrimitiveArray(data, "suggested_tip_amounts"); + } parse(data, "provider_data", &result->providerData); parse(data, "photo_url", &result->photoUrl); parse(data, "photo_size", &result->photoSize); @@ -4373,7 +4379,7 @@ DECLARE_PARSER_TO_JSON(InputInvoiceMessageContent) { ptree.put("currency", object->currency); ptree.put("prices", put(object->prices)); ptree.put("max_tip_amount", object->maxTipAmount); - ptree.put("suggested_tip_amounts", put(object->suggestedTipAmounts)); + ptree.put("suggested_tip_amounts", object->suggestedTipAmounts); ptree.put("provider_data", object->providerData); ptree.put("photo_url", object->photoUrl); ptree.put("photo_size", object->photoSize);