Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/tgbot/types/CallbackQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "tgbot/types/Message.h"

#include <memory>
#include <optional>
#include <string>

namespace TgBot {
Expand Down Expand Up @@ -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<std::string> 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.
Expand Down
2 changes: 1 addition & 1 deletion include/tgbot/types/InputInvoiceMessageContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::int32_t> suggestedTipAmounts;
std::optional<std::vector<std::int32_t>> suggestedTipAmounts;

/**
* @brief Optional. A JSON-serialized object for data about the invoice, which will be shared with the payment provider.
Expand Down
3 changes: 2 additions & 1 deletion include/tgbot/types/InputSticker.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "tgbot/types/MaskPosition.h"

#include <memory>
#include <optional>
#include <string>
#include <vector>

Expand Down Expand Up @@ -50,7 +51,7 @@ class InputSticker {
*
* For “regular” and “custom_emoji” stickers only.
*/
std::vector<std::string> keywords;
std::optional<std::vector<std::string>> keywords;
};
}

Expand Down
2 changes: 1 addition & 1 deletion include/tgbot/types/Message.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class Message {
/**
* @brief Optional. Caption for the animation, audio, document, photo, video or voice
*/
std::string caption;
std::optional<std::string> caption;

/**
* @brief Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
Expand Down
2 changes: 1 addition & 1 deletion include/tgbot/types/WebhookInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> allowedUpdates;
std::optional<std::vector<std::string>> allowedUpdates;
};
}

Expand Down
22 changes: 14 additions & 8 deletions src/TgTypeParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>(data, "allowed_updates");
if (data.contains("allowed_updates") && !data["allowed_updates"].is_null()) {
result->allowedUpdates =
parsePrimitiveArray<std::string>(data, "allowed_updates");
}
return result;
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -3489,7 +3491,9 @@ DECLARE_PARSER_FROM_JSON(InputSticker) {
parse(data, "format", &result->format);
result->emojiList = parsePrimitiveArray<std::string>(data, "emoji_list");
result->maskPosition = parse<MaskPosition>(data, "mask_position");
result->keywords = parsePrimitiveArray<std::string>(data, "keywords");
if (data.contains("keywords") && !data["keywords"].is_null()) {
result->keywords = parsePrimitiveArray<std::string>(data, "keywords");
}
return result;
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -4343,8 +4347,10 @@ DECLARE_PARSER_FROM_JSON(InputInvoiceMessageContent) {
parse(data, "currency", &result->currency);
result->prices = parseArray<LabeledPrice>(data, "prices");
parse(data, "max_tip_amount", &result->maxTipAmount);
result->suggestedTipAmounts =
parsePrimitiveArray<std::int32_t>(data, "suggested_tip_amounts");
if (data.contains("suggested_tip_amounts") && !data["suggested_tip_amounts"].is_null()) {
result->suggestedTipAmounts =
parsePrimitiveArray<std::int32_t>(data, "suggested_tip_amounts");
}
parse(data, "provider_data", &result->providerData);
parse(data, "photo_url", &result->photoUrl);
parse(data, "photo_size", &result->photoSize);
Expand Down Expand Up @@ -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);
Expand Down