From 70fdce95df4998ae4e54df4006859a3770a59478 Mon Sep 17 00:00:00 2001 From: YJBeetle Date: Sun, 17 Nov 2019 14:41:17 +0200 Subject: Fix InlineQueryResult parse bug --- include/tgbot/TgTypeParser.h | 582 ++++++++++++++++++++++--------------------- 1 file changed, 300 insertions(+), 282 deletions(-) (limited to 'include') diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index dbfa27e..eeda4cd 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -106,378 +106,396 @@ namespace TgBot { -class TgTypeParser { + class TgTypeParser { -public: - template - using JsonToTgTypeFunc = std::shared_ptr (TgTypeParser::*)(const boost::property_tree::ptree&) const; + public: + template + using JsonToTgTypeFunc = std::shared_ptr (TgTypeParser::*)(const boost::property_tree::ptree&) const; - template - using TgTypeToJsonFunc = std::string (TgTypeParser::*)(const std::shared_ptr&) const; + template + using TgTypeToJsonFunc = std::string (TgTypeParser::*)(const std::shared_ptr&) const; - Chat::Ptr parseJsonAndGetChat(const boost::property_tree::ptree& data) const; - std::string parseChat(const Chat::Ptr& object) const; + Chat::Ptr parseJsonAndGetChat(const boost::property_tree::ptree& data) const; + std::string parseChat(const Chat::Ptr& object) const; - User::Ptr parseJsonAndGetUser(const boost::property_tree::ptree& data) const; - std::string parseUser(const User::Ptr& object) const; + User::Ptr parseJsonAndGetUser(const boost::property_tree::ptree& data) const; + std::string parseUser(const User::Ptr& object) const; - MessageEntity::Ptr parseJsonAndGetMessageEntity(const boost::property_tree::ptree& data) const; - std::string parseMessageEntity(const MessageEntity::Ptr& object) const; + MessageEntity::Ptr parseJsonAndGetMessageEntity(const boost::property_tree::ptree& data) const; + std::string parseMessageEntity(const MessageEntity::Ptr& object) const; - Message::Ptr parseJsonAndGetMessage(const boost::property_tree::ptree& data) const; - std::string parseMessage(const Message::Ptr& object) const; + Message::Ptr parseJsonAndGetMessage(const boost::property_tree::ptree& data) const; + std::string parseMessage(const Message::Ptr& object) const; - PhotoSize::Ptr parseJsonAndGetPhotoSize(const boost::property_tree::ptree& data) const; - std::string parsePhotoSize(const PhotoSize::Ptr& object) const; + PhotoSize::Ptr parseJsonAndGetPhotoSize(const boost::property_tree::ptree& data) const; + std::string parsePhotoSize(const PhotoSize::Ptr& object) const; - Audio::Ptr parseJsonAndGetAudio(const boost::property_tree::ptree& data) const; - std::string parseAudio(const Audio::Ptr& object) const; + Audio::Ptr parseJsonAndGetAudio(const boost::property_tree::ptree& data) const; + std::string parseAudio(const Audio::Ptr& object) const; - Document::Ptr parseJsonAndGetDocument(const boost::property_tree::ptree& data) const; - std::string parseDocument(const Document::Ptr& object) const; + Document::Ptr parseJsonAndGetDocument(const boost::property_tree::ptree& data) const; + std::string parseDocument(const Document::Ptr& object) const; - Sticker::Ptr parseJsonAndGetSticker(const boost::property_tree::ptree& data) const; - std::string parseSticker(const Sticker::Ptr& object) const; + Sticker::Ptr parseJsonAndGetSticker(const boost::property_tree::ptree& data) const; + std::string parseSticker(const Sticker::Ptr& object) const; - StickerSet::Ptr parseJsonAndGetStickerSet(const boost::property_tree::ptree& data) const; - std::string parseStickerSet(const StickerSet::Ptr& object) const; + StickerSet::Ptr parseJsonAndGetStickerSet(const boost::property_tree::ptree& data) const; + std::string parseStickerSet(const StickerSet::Ptr& object) const; - MaskPosition::Ptr parseJsonAndGetMaskPosition(const boost::property_tree::ptree& data) const; - std::string parseMaskPosition(const MaskPosition::Ptr& object) const; + MaskPosition::Ptr parseJsonAndGetMaskPosition(const boost::property_tree::ptree& data) const; + std::string parseMaskPosition(const MaskPosition::Ptr& object) const; - Video::Ptr parseJsonAndGetVideo(const boost::property_tree::ptree& data) const; - std::string parseVideo(const Video::Ptr& object) const; + Video::Ptr parseJsonAndGetVideo(const boost::property_tree::ptree& data) const; + std::string parseVideo(const Video::Ptr& object) const; - Voice::Ptr parseJsonAndGetVoice(const boost::property_tree::ptree& data) const; - std::string parseVoice(const Voice::Ptr& object) const; + Voice::Ptr parseJsonAndGetVoice(const boost::property_tree::ptree& data) const; + std::string parseVoice(const Voice::Ptr& object) const; - VideoNote::Ptr parseJsonAndGetVideoNote(const boost::property_tree::ptree& data) const; - std::string parseVideoNote(const VideoNote::Ptr& object) const; + VideoNote::Ptr parseJsonAndGetVideoNote(const boost::property_tree::ptree& data) const; + std::string parseVideoNote(const VideoNote::Ptr& object) const; - Game::Ptr parseJsonAndGetGame(const boost::property_tree::ptree& data) const; - std::string parseGame(const Game::Ptr& object) const; + Game::Ptr parseJsonAndGetGame(const boost::property_tree::ptree& data) const; + std::string parseGame(const Game::Ptr& object) const; - GameHighScore::Ptr parseJsonAndGetGameHighScore(const boost::property_tree::ptree& data) const; - std::string parseGameHighScore(const GameHighScore::Ptr& object) const; + GameHighScore::Ptr parseJsonAndGetGameHighScore(const boost::property_tree::ptree& data) const; + std::string parseGameHighScore(const GameHighScore::Ptr& object) const; - Animation::Ptr parseJsonAndGetAnimation(const boost::property_tree::ptree& data) const; - std::string parseAnimation(const Animation::Ptr& object) const; + Animation::Ptr parseJsonAndGetAnimation(const boost::property_tree::ptree& data) const; + std::string parseAnimation(const Animation::Ptr& object) const; - Contact::Ptr parseJsonAndGetContact(const boost::property_tree::ptree& data) const; - std::string parseContact(const Contact::Ptr& object) const; + Contact::Ptr parseJsonAndGetContact(const boost::property_tree::ptree& data) const; + std::string parseContact(const Contact::Ptr& object) const; - Location::Ptr parseJsonAndGetLocation(const boost::property_tree::ptree& data) const; - std::string parseLocation(const Location::Ptr& object) const; + Location::Ptr parseJsonAndGetLocation(const boost::property_tree::ptree& data) const; + std::string parseLocation(const Location::Ptr& object) const; - Update::Ptr parseJsonAndGetUpdate(const boost::property_tree::ptree& data) const; - std::string parseUpdate(const Update::Ptr& object) const; + Update::Ptr parseJsonAndGetUpdate(const boost::property_tree::ptree& data) const; + std::string parseUpdate(const Update::Ptr& object) const; - UserProfilePhotos::Ptr parseJsonAndGetUserProfilePhotos(const boost::property_tree::ptree& data) const; - std::string parseUserProfilePhotos(const UserProfilePhotos::Ptr& object) const; + UserProfilePhotos::Ptr parseJsonAndGetUserProfilePhotos(const boost::property_tree::ptree& data) const; + std::string parseUserProfilePhotos(const UserProfilePhotos::Ptr& object) const; - InputMedia::Ptr parseJsonAndGetInputMedia(const boost::property_tree::ptree& data) const; - std::string parseInputMedia(const InputMedia::Ptr& object) const; + InputMedia::Ptr parseJsonAndGetInputMedia(const boost::property_tree::ptree& data) const; + std::string parseInputMedia(const InputMedia::Ptr& object) const; - File::Ptr parseJsonAndGetFile(const boost::property_tree::ptree& data) const; - std::string parseFile(const File::Ptr& object) const; + File::Ptr parseJsonAndGetFile(const boost::property_tree::ptree& data) const; + std::string parseFile(const File::Ptr& object) const; - ReplyKeyboardMarkup::Ptr parseJsonAndGetReplyKeyboardMarkup(const boost::property_tree::ptree& data) const; - std::string parseReplyKeyboardMarkup(const ReplyKeyboardMarkup::Ptr& object) const; + ReplyKeyboardMarkup::Ptr parseJsonAndGetReplyKeyboardMarkup(const boost::property_tree::ptree& data) const; + std::string parseReplyKeyboardMarkup(const ReplyKeyboardMarkup::Ptr& object) const; - KeyboardButton::Ptr parseJsonAndGetKeyboardButton(const boost::property_tree::ptree& data) const; - std::string parseKeyboardButton(const KeyboardButton::Ptr& object) const; + KeyboardButton::Ptr parseJsonAndGetKeyboardButton(const boost::property_tree::ptree& data) const; + std::string parseKeyboardButton(const KeyboardButton::Ptr& object) const; - ReplyKeyboardRemove::Ptr parseJsonAndGetReplyKeyboardRemove(const boost::property_tree::ptree& data) const; - std::string parseReplyKeyboardRemove(const ReplyKeyboardRemove::Ptr& object) const; + ReplyKeyboardRemove::Ptr parseJsonAndGetReplyKeyboardRemove(const boost::property_tree::ptree& data) const; + std::string parseReplyKeyboardRemove(const ReplyKeyboardRemove::Ptr& object) const; - ForceReply::Ptr parseJsonAndGetForceReply(const boost::property_tree::ptree& data) const; - std::string parseForceReply(const ForceReply::Ptr& object) const; + ForceReply::Ptr parseJsonAndGetForceReply(const boost::property_tree::ptree& data) const; + std::string parseForceReply(const ForceReply::Ptr& object) const; - ChatMember::Ptr parseJsonAndGetChatMember(const boost::property_tree::ptree& data) const; - std::string parseChatMember(const ChatMember::Ptr& object) const; + ChatMember::Ptr parseJsonAndGetChatMember(const boost::property_tree::ptree& data) const; + std::string parseChatMember(const ChatMember::Ptr& object) const; - ChatPhoto::Ptr parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const; - std::string parseChatPhoto(const ChatPhoto::Ptr& object) const; + ChatPhoto::Ptr parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const; + std::string parseChatPhoto(const ChatPhoto::Ptr& object) const; - ResponseParameters::Ptr parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const; - std::string parseResponseParameters(const ResponseParameters::Ptr& object) const; + ResponseParameters::Ptr parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const; + std::string parseResponseParameters(const ResponseParameters::Ptr& object) const; - GenericReply::Ptr parseJsonAndGetGenericReply(const boost::property_tree::ptree& data) const; - std::string parseGenericReply(const GenericReply::Ptr& object) const; + GenericReply::Ptr parseJsonAndGetGenericReply(const boost::property_tree::ptree& data) const; + std::string parseGenericReply(const GenericReply::Ptr& object) const; - InlineQuery::Ptr parseJsonAndGetInlineQuery(const boost::property_tree::ptree& data) const; - std::string parseInlineQuery(const InlineQuery::Ptr& object) const; + InlineQuery::Ptr parseJsonAndGetInlineQuery(const boost::property_tree::ptree& data) const; + std::string parseInlineQuery(const InlineQuery::Ptr& object) const; - InlineQueryResult::Ptr parseJsonAndGetInlineQueryResult(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResult(const InlineQueryResult::Ptr& object) const; + InlineQueryResult::Ptr parseJsonAndGetInlineQueryResult(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResult(const InlineQueryResult::Ptr& object) const; - InlineQueryResultCachedAudio::Ptr parseJsonAndGetInlineQueryResultCachedAudio(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedAudio(const InlineQueryResultCachedAudio::Ptr& object) const; + InlineQueryResultCachedAudio::Ptr parseJsonAndGetInlineQueryResultCachedAudio(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedAudio(const InlineQueryResultCachedAudio::Ptr& object) const; - InlineQueryResultCachedDocument::Ptr parseJsonAndGetInlineQueryResultCachedDocument(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedDocument(const InlineQueryResultCachedDocument::Ptr& object) const; + InlineQueryResultCachedDocument::Ptr parseJsonAndGetInlineQueryResultCachedDocument(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedDocument(const InlineQueryResultCachedDocument::Ptr& object) const; - InlineQueryResultCachedGif::Ptr parseJsonAndGetInlineQueryResultCachedGif(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedGif(const InlineQueryResultCachedGif::Ptr& object) const; + InlineQueryResultCachedGif::Ptr parseJsonAndGetInlineQueryResultCachedGif(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedGif(const InlineQueryResultCachedGif::Ptr& object) const; - InlineQueryResultCachedMpeg4Gif::Ptr parseJsonAndGetInlineQueryResultCachedMpeg4Gif(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedMpeg4Gif(const InlineQueryResultCachedMpeg4Gif::Ptr& object) const; + InlineQueryResultCachedMpeg4Gif::Ptr parseJsonAndGetInlineQueryResultCachedMpeg4Gif(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedMpeg4Gif(const InlineQueryResultCachedMpeg4Gif::Ptr& object) const; - InlineQueryResultCachedPhoto::Ptr parseJsonAndGetInlineQueryResultCachedPhoto(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedPhoto(const InlineQueryResultCachedPhoto::Ptr& object) const; + InlineQueryResultCachedPhoto::Ptr parseJsonAndGetInlineQueryResultCachedPhoto(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedPhoto(const InlineQueryResultCachedPhoto::Ptr& object) const; - InlineQueryResultCachedSticker::Ptr parseJsonAndGetInlineQueryResultCachedSticker(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedSticker(const InlineQueryResultCachedSticker::Ptr& object) const; + InlineQueryResultCachedSticker::Ptr parseJsonAndGetInlineQueryResultCachedSticker(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedSticker(const InlineQueryResultCachedSticker::Ptr& object) const; - InlineQueryResultCachedVideo::Ptr parseJsonAndGetInlineQueryResultCachedVideo(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedVideo(const InlineQueryResultCachedVideo::Ptr& object) const; + InlineQueryResultCachedVideo::Ptr parseJsonAndGetInlineQueryResultCachedVideo(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedVideo(const InlineQueryResultCachedVideo::Ptr& object) const; - InlineQueryResultCachedVoice::Ptr parseJsonAndGetInlineQueryResultCachedVoice(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultCachedVoice(const InlineQueryResultCachedVoice::Ptr& object) const; + InlineQueryResultCachedVoice::Ptr parseJsonAndGetInlineQueryResultCachedVoice(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultCachedVoice(const InlineQueryResultCachedVoice::Ptr& object) const; - InlineQueryResultArticle::Ptr parseJsonAndGetInlineQueryResultArticle(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultArticle(const InlineQueryResultArticle::Ptr& object) const; + InlineQueryResultArticle::Ptr parseJsonAndGetInlineQueryResultArticle(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultArticle(const InlineQueryResultArticle::Ptr& object) const; - InlineQueryResultAudio::Ptr parseJsonAndGetInlineQueryResultAudio(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultAudio(const InlineQueryResultAudio::Ptr& object) const; + InlineQueryResultAudio::Ptr parseJsonAndGetInlineQueryResultAudio(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultAudio(const InlineQueryResultAudio::Ptr& object) const; - InlineQueryResultContact::Ptr parseJsonAndGetInlineQueryResultContact(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultContact(const InlineQueryResultContact::Ptr& object) const; + InlineQueryResultContact::Ptr parseJsonAndGetInlineQueryResultContact(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultContact(const InlineQueryResultContact::Ptr& object) const; - InlineQueryResultGame::Ptr parseJsonAndGetInlineQueryResultGame(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultGame(const InlineQueryResultGame::Ptr& object) const; + InlineQueryResultGame::Ptr parseJsonAndGetInlineQueryResultGame(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultGame(const InlineQueryResultGame::Ptr& object) const; - InlineQueryResultDocument::Ptr parseJsonAndGetInlineQueryResultDocument(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultDocument(const InlineQueryResultDocument::Ptr& object) const; + InlineQueryResultDocument::Ptr parseJsonAndGetInlineQueryResultDocument(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultDocument(const InlineQueryResultDocument::Ptr& object) const; - InlineQueryResultLocation::Ptr parseJsonAndGetInlineQueryResultLocation(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultLocation(const InlineQueryResultLocation::Ptr& object) const; + InlineQueryResultLocation::Ptr parseJsonAndGetInlineQueryResultLocation(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultLocation(const InlineQueryResultLocation::Ptr& object) const; - InlineQueryResultVenue::Ptr parseJsonAndGetInlineQueryResultVenue(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultVenue(const InlineQueryResultVenue::Ptr& object) const; + InlineQueryResultVenue::Ptr parseJsonAndGetInlineQueryResultVenue(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultVenue(const InlineQueryResultVenue::Ptr& object) const; - InlineQueryResultVoice::Ptr parseJsonAndGetInlineQueryResultVoice(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultVoice(const InlineQueryResultVoice::Ptr& object) const; + InlineQueryResultVoice::Ptr parseJsonAndGetInlineQueryResultVoice(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultVoice(const InlineQueryResultVoice::Ptr& object) const; - InlineQueryResultPhoto::Ptr parseJsonAndGetInlineQueryResultPhoto(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultPhoto(const InlineQueryResultPhoto::Ptr& object) const; + InlineQueryResultPhoto::Ptr parseJsonAndGetInlineQueryResultPhoto(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultPhoto(const InlineQueryResultPhoto::Ptr& object) const; - InlineQueryResultGif::Ptr parseJsonAndGetInlineQueryResultGif(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultGif(const InlineQueryResultGif::Ptr& object) const; + InlineQueryResultGif::Ptr parseJsonAndGetInlineQueryResultGif(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultGif(const InlineQueryResultGif::Ptr& object) const; - InlineQueryResultMpeg4Gif::Ptr parseJsonAndGetInlineQueryResultMpeg4Gif(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultMpeg4Gif(const InlineQueryResultMpeg4Gif::Ptr& object) const; + InlineQueryResultMpeg4Gif::Ptr parseJsonAndGetInlineQueryResultMpeg4Gif(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultMpeg4Gif(const InlineQueryResultMpeg4Gif::Ptr& object) const; - InlineQueryResultVideo::Ptr parseJsonAndGetInlineQueryResultVideo(const boost::property_tree::ptree& data) const; - std::string parseInlineQueryResultVideo(const InlineQueryResultVideo::Ptr& object) const; + InlineQueryResultVideo::Ptr parseJsonAndGetInlineQueryResultVideo(const boost::property_tree::ptree& data) const; + std::string parseInlineQueryResultVideo(const InlineQueryResultVideo::Ptr& object) const; - ChosenInlineResult::Ptr parseJsonAndGetChosenInlineResult(const boost::property_tree::ptree& data) const; - std::string parseChosenInlineResult(const ChosenInlineResult::Ptr& object) const; + ChosenInlineResult::Ptr parseJsonAndGetChosenInlineResult(const boost::property_tree::ptree& data) const; + std::string parseChosenInlineResult(const ChosenInlineResult::Ptr& object) const; - CallbackQuery::Ptr parseJsonAndGetCallbackQuery(const boost::property_tree::ptree& data) const; - std::string parseCallbackQuery(const CallbackQuery::Ptr& object) const; + CallbackQuery::Ptr parseJsonAndGetCallbackQuery(const boost::property_tree::ptree& data) const; + std::string parseCallbackQuery(const CallbackQuery::Ptr& object) const; - InlineKeyboardMarkup::Ptr parseJsonAndGetInlineKeyboardMarkup(const boost::property_tree::ptree& data) const; - std::string parseInlineKeyboardMarkup(const InlineKeyboardMarkup::Ptr& object) const; + InlineKeyboardMarkup::Ptr parseJsonAndGetInlineKeyboardMarkup(const boost::property_tree::ptree& data) const; + std::string parseInlineKeyboardMarkup(const InlineKeyboardMarkup::Ptr& object) const; - InlineKeyboardButton::Ptr parseJsonAndGetInlineKeyboardButton(const boost::property_tree::ptree& data) const; - std::string parseInlineKeyboardButton(const InlineKeyboardButton::Ptr& object) const; + InlineKeyboardButton::Ptr parseJsonAndGetInlineKeyboardButton(const boost::property_tree::ptree& data) const; + std::string parseInlineKeyboardButton(const InlineKeyboardButton::Ptr& object) const; - WebhookInfo::Ptr parseJsonAndGetWebhookInfo(const boost::property_tree::ptree& data) const; - std::string parseWebhookInfo(const WebhookInfo::Ptr& object) const; + WebhookInfo::Ptr parseJsonAndGetWebhookInfo(const boost::property_tree::ptree& data) const; + std::string parseWebhookInfo(const WebhookInfo::Ptr& object) const; - InputMessageContent::Ptr parseJsonAndGetInputMessageContent(const boost::property_tree::ptree& data) const; - std::string parseInputMessageContent(const InputMessageContent::Ptr& object) const; + InputMessageContent::Ptr parseJsonAndGetInputMessageContent(const boost::property_tree::ptree& data) const; + std::string parseInputMessageContent(const InputMessageContent::Ptr& object) const; - InputTextMessageContent::Ptr parseJsonAndGetInputTextMessageContent(const boost::property_tree::ptree& data) const; - std::string parseInputTextMessageContent(const InputTextMessageContent::Ptr& object) const; + InputTextMessageContent::Ptr parseJsonAndGetInputTextMessageContent(const boost::property_tree::ptree& data) const; + std::string parseInputTextMessageContent(const InputTextMessageContent::Ptr& object) const; - InputLocationMessageContent::Ptr parseJsonAndGetInputLocationMessageContent(const boost::property_tree::ptree& data) const; - std::string parseInputLocationMessageContent(const InputLocationMessageContent::Ptr& object) const; + InputLocationMessageContent::Ptr parseJsonAndGetInputLocationMessageContent(const boost::property_tree::ptree& data) const; + std::string parseInputLocationMessageContent(const InputLocationMessageContent::Ptr& object) const; - InputVenueMessageContent::Ptr parseJsonAndGetInputVenueMessageContent(const boost::property_tree::ptree& data) const; - std::string parseInputVenueMessageContent(const InputVenueMessageContent::Ptr& object) const; + InputVenueMessageContent::Ptr parseJsonAndGetInputVenueMessageContent(const boost::property_tree::ptree& data) const; + std::string parseInputVenueMessageContent(const InputVenueMessageContent::Ptr& object) const; - InputContactMessageContent::Ptr parseJsonAndGetInputContactMessageContent(const boost::property_tree::ptree& data) const; - std::string parseInputContactMessageContent(const InputContactMessageContent::Ptr& object) const; + InputContactMessageContent::Ptr parseJsonAndGetInputContactMessageContent(const boost::property_tree::ptree& data) const; + std::string parseInputContactMessageContent(const InputContactMessageContent::Ptr& object) const; - Invoice::Ptr parseJsonAndGetInvoice(const boost::property_tree::ptree& data) const; - std::string parseInvoice(const Invoice::Ptr& object) const; + Invoice::Ptr parseJsonAndGetInvoice(const boost::property_tree::ptree& data) const; + std::string parseInvoice(const Invoice::Ptr& object) const; - LabeledPrice::Ptr parseJsonAndGetLabeledPrice(const boost::property_tree::ptree& data) const; - std::string parseLabeledPrice(const LabeledPrice::Ptr& object) const; + LabeledPrice::Ptr parseJsonAndGetLabeledPrice(const boost::property_tree::ptree& data) const; + std::string parseLabeledPrice(const LabeledPrice::Ptr& object) const; - OrderInfo::Ptr parseJsonAndGetOrderInfo(const boost::property_tree::ptree& data) const; - std::string parseOrderInfo(const OrderInfo::Ptr& object) const; + OrderInfo::Ptr parseJsonAndGetOrderInfo(const boost::property_tree::ptree& data) const; + std::string parseOrderInfo(const OrderInfo::Ptr& object) const; - PreCheckoutQuery::Ptr parseJsonAndGetPreCheckoutQuery(const boost::property_tree::ptree& data) const; - std::string parsePreCheckoutQuery(const PreCheckoutQuery::Ptr& object) const; + PreCheckoutQuery::Ptr parseJsonAndGetPreCheckoutQuery(const boost::property_tree::ptree& data) const; + std::string parsePreCheckoutQuery(const PreCheckoutQuery::Ptr& object) const; - ShippingAddress::Ptr parseJsonAndGetShippingAddress(const boost::property_tree::ptree& data) const; - std::string parseShippingAddress(const ShippingAddress::Ptr& object) const; + ShippingAddress::Ptr parseJsonAndGetShippingAddress(const boost::property_tree::ptree& data) const; + std::string parseShippingAddress(const ShippingAddress::Ptr& object) const; - ShippingOption::Ptr parseJsonAndGetShippingOption(const boost::property_tree::ptree& data) const; - std::string parseShippingOption(const ShippingOption::Ptr& object) const; + ShippingOption::Ptr parseJsonAndGetShippingOption(const boost::property_tree::ptree& data) const; + std::string parseShippingOption(const ShippingOption::Ptr& object) const; - ShippingQuery::Ptr parseJsonAndGetShippingQuery(const boost::property_tree::ptree& data) const; - std::string parseShippingQuery(const ShippingQuery::Ptr& object) const; + ShippingQuery::Ptr parseJsonAndGetShippingQuery(const boost::property_tree::ptree& data) const; + std::string parseShippingQuery(const ShippingQuery::Ptr& object) const; - SuccessfulPayment::Ptr parseJsonAndGetSuccessfulPayment(const boost::property_tree::ptree& data) const; - std::string parseSuccessfulPayment(const SuccessfulPayment::Ptr& object) const; + SuccessfulPayment::Ptr parseJsonAndGetSuccessfulPayment(const boost::property_tree::ptree& data) const; + std::string parseSuccessfulPayment(const SuccessfulPayment::Ptr& object) const; - inline boost::property_tree::ptree parseJson(const std::string& json) const { - boost::property_tree::ptree tree; - std::istringstream input(json); - boost::property_tree::read_json(input, tree); - return tree; - } + inline boost::property_tree::ptree parseJson(const std::string& json) const { + boost::property_tree::ptree tree; + std::istringstream input(json); + boost::property_tree::read_json(input, tree); + return tree; + } - template - std::shared_ptr tryParseJson(JsonToTgTypeFunc parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { - auto treeItem = data.find(keyName); - if (treeItem == data.not_found()) { - return std::shared_ptr(); + template + std::shared_ptr tryParseJson(JsonToTgTypeFunc parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { + auto treeItem = data.find(keyName); + if (treeItem == data.not_found()) { + return std::shared_ptr(); + } + return (this->*parseFunc)(treeItem->second); } - return (this->*parseFunc)(treeItem->second); - } - - template - std::vector> parseJsonAndGetArray(JsonToTgTypeFunc parseFunc, const boost::property_tree::ptree& data) const { - std::vector> result; - result.reserve(data.size()); - for (const std::pair& innerTreeItem : data) { - result.push_back((this->*parseFunc)(innerTreeItem.second)); + + template + std::vector> parseJsonAndGetArray(JsonToTgTypeFunc parseFunc, const boost::property_tree::ptree& data) const { + std::vector> result; + result.reserve(data.size()); + for (const std::pair& innerTreeItem : data) { + result.push_back((this->*parseFunc)(innerTreeItem.second)); + } + return result; } - return result; - } - - template - std::vector parseJsonAndGetArray(std::function parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { - std::vector result; - auto treeItem = data.find(keyName); - if (treeItem == data.not_found()) { + + template + std::vector parseJsonAndGetArray(std::function parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { + std::vector result; + auto treeItem = data.find(keyName); + if (treeItem == data.not_found()) { + return result; + } + result.reserve(treeItem->second.size()); + for (const std::pair& innerTreeItem : treeItem->second) { + result.push_back(parseFunc(innerTreeItem.second)); + } return result; } - result.reserve(treeItem->second.size()); - for (const std::pair& innerTreeItem : treeItem->second) { - result.push_back(parseFunc(innerTreeItem.second)); + + template + std::vector> parseJsonAndGetArray(JsonToTgTypeFunc parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { + std::vector> result; + auto treeItem = data.find(keyName); + if (treeItem == data.not_found()) { + return result; + } + result.reserve(treeItem->second.size()); + for (const std::pair& innerTreeItem : treeItem->second) { + result.push_back((this->*parseFunc)(innerTreeItem.second)); + } + return result; } - return result; - } - - template - std::vector> parseJsonAndGetArray(JsonToTgTypeFunc parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { - std::vector> result; - auto treeItem = data.find(keyName); - if (treeItem == data.not_found()) { + + template + std::vector>> parseJsonAndGet2DArray(JsonToTgTypeFunc parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { + std::vector>> result; + auto treeItem = data.find(keyName); + if (treeItem == data.not_found()) { + return result; + } + result.reserve(treeItem->second.size()); + for (const std::pair& innerTreeItem : treeItem->second) { + std::vector> innerResult; + for (const std::pair& innerInnerTreeItem : innerTreeItem.second) { + innerResult.push_back((this->*parseFunc)(innerInnerTreeItem.second)); + } + result.push_back(innerResult); + } return result; } - result.reserve(treeItem->second.size()); - for (const std::pair& innerTreeItem : treeItem->second) { - result.push_back((this->*parseFunc)(innerTreeItem.second)); + + template + std::string parseArray(TgTypeToJsonFunc parseFunc, const std::vector>& objects) const { + if (objects.empty()) + return ""; + std::string result; + result += '['; + for (const std::shared_ptr& item : objects) { + result += (this->*parseFunc)(item); + result += ','; + } + result.erase(result.length() - 1); + result += ']'; + return result; } - return result; - } - - template - std::vector>> parseJsonAndGet2DArray(JsonToTgTypeFunc parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { - std::vector>> result; - auto treeItem = data.find(keyName); - if (treeItem == data.not_found()) { + + template + std::string parseArray(std::function parseFunc, const std::vector& objects) const { + if (objects.empty()) + return ""; + std::string result; + result += '['; + for (const T& item : objects) { + result += parseFunc(item); + result += ','; + } + result.erase(result.length() - 1); + result += ']'; return result; } - result.reserve(treeItem->second.size()); - for (const std::pair& innerTreeItem : treeItem->second) { - std::vector> innerResult; - for (const std::pair& innerInnerTreeItem : innerTreeItem.second) { - innerResult.push_back((this->*parseFunc)(innerInnerTreeItem.second)); + + template + std::string parse2DArray(TgTypeToJsonFunc parseFunc, const std::vector>>& objects) const { + if (objects.empty()) + return ""; + std::string result; + result += '['; + for (const std::vector>& item : objects) { + result += parseArray(parseFunc, item); + result += ','; } - result.push_back(innerResult); + result.erase(result.length() - 1); + result += ']'; + return result; } - return result; - } - - template - std::string parseArray(TgTypeToJsonFunc parseFunc, const std::vector>& objects) const { - if (objects.empty()) - return ""; - std::string result; - result += '['; - for (const std::shared_ptr& item : objects) { - result += (this->*parseFunc)(item); - result += ','; + + private: + inline void removeLastComma(std::string& input) const { + input.erase(input.length() - 1); } - result.erase(result.length() - 1); - result += ']'; - return result; - } - - template - std::string parseArray(std::function parseFunc, const std::vector& objects) const { - if (objects.empty()) - return ""; - std::string result; - result += '['; - for (const T& item : objects) { - result += parseFunc(item); - result += ','; + + template + inline void appendToJson(std::string& json, const std::string& varName, const std::shared_ptr& value) const { + if (value == nullptr) { + return; + } + json += '"'; + json += varName; + json += R"(":)"; + json += value; + json += ','; } - result.erase(result.length() - 1); - result += ']'; - return result; - } - - template - std::string parse2DArray(TgTypeToJsonFunc parseFunc, const std::vector>>& objects) const { - if (objects.empty()) - return ""; - std::string result; - result += '['; - for (const std::vector>& item : objects) { - result += parseArray(parseFunc, item); - result += ','; + + template + inline void appendToJson(std::string& json, const std::string& varName, const T& value) const { + json += '"'; + json += varName; + json += R"(":)"; + json += value; + json += ','; } - result.erase(result.length() - 1); - result += ']'; - return result; - } - -private: - inline void removeLastComma(std::string& input) const { - input.erase(input.length() - 1); - } - - template - inline void appendToJson(std::string& json, const std::string& varName, const std::shared_ptr& value) const { - if (value == nullptr) { - return; + + template + inline void appendToJsonNumber(std::string& json, const std::string& varName, const T& value) const { + json += '"'; + json += varName; + json += R"(":)"; + json += std::to_string(value); + json += ','; + } + inline void appendToJson(std::string &json, const std::string &varName, const int &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const long &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const long long &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const unsigned &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const unsigned long &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const unsigned long long &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const float &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const double &value) const { appendToJsonNumber(json, varName, value); } + inline void appendToJson(std::string &json, const std::string &varName, const long double &value) const { appendToJsonNumber(json, varName, value); } + + inline void appendToJson(std::string& json, const std::string& varName, const bool& value) const { + json += '"'; + json += varName; + json += R"(":)"; + json += (value ? "true" : "false"); + json += ','; } - json += '"'; - json += varName; - json += R"(":)"; - json += value; - json += ','; - } - - template - inline void appendToJson(std::string& json, const std::string& varName, const T& value) const { - json += '"'; - json += varName; - json += R"(":)"; - json += value; - json += ','; - } - - inline void appendToJson(std::string& json, const std::string& varName, const bool& value) const { - json += '"'; - json += varName; - json += R"(":)"; - json += (value ? "true" : "false"); - json += ','; - } - - void appendToJson(std::string& json, const std::string& varName, const std::string& value) const; -}; + + void appendToJson(std::string& json, const std::string& varName, const std::string& value) const; + }; } -- cgit v1.2.3 From 23553bc251ca673137b684082a6f84062f053bd2 Mon Sep 17 00:00:00 2001 From: nitanmarcel Date: Tue, 19 Nov 2019 21:31:44 +0200 Subject: API 4.2 --- include/tgbot/Api.h | 39 +++++++++++++++++++++---- include/tgbot/TgTypeParser.h | 8 +++++ include/tgbot/types/ChatMember.h | 5 ++++ include/tgbot/types/Message.h | 11 +++++++ include/tgbot/types/Poll.h | 63 ++++++++++++++++++++++++++++++++++++++++ include/tgbot/types/PollOption.h | 46 +++++++++++++++++++++++++++++ 6 files changed, 166 insertions(+), 6 deletions(-) create mode 100644 include/tgbot/types/Poll.h create mode 100644 include/tgbot/types/PollOption.h (limited to 'include') diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 84a6c9b..184f3a1 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -291,6 +291,7 @@ public: * @param disableNotification Optional. Sends the message silenty. * @return On success, the sent message is returned. */ + Message::Ptr sendVideo(int64_t chatId, const boost::variant video, bool supportsStreaming = false, int32_t duration = 0, int32_t width = 0, int32_t height = 0, const boost::variant thumb = "", const std::string& caption = "", int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared(), const std::string& parseMode = "", bool disableNotification = false) const; @@ -585,7 +586,7 @@ public: /** * @brief Use this method to delete messages sent by bot (or by other users if bot is admin). - * @param chatId Unique identifier for the target chat. + * @param chatId Unique identifier for the target chat or username of the target channel. * @param messageId Unique identifier for the target message. */ void deleteMessage(int64_t chatId, int32_t messageId) const; @@ -746,8 +747,8 @@ public: bool setChatDescription(int64_t chatId, const std::string& description) const; /** - * @brief Use this method to pin a message in a supergroup or a channel. - * @param chatId Unique identifier for the target chat. + * @brief Use this method to pin a message in a group, a supergroup, or a channel. + * @param chatId Unique identifier for the target chat or username of the target channel. * @param messageId Identifier of a message to pin. * @param disableNotification Optional. Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels. * @return True on success @@ -755,8 +756,8 @@ public: bool pinChatMessage(int64_t chatId, int32_t messageId, bool disableNotification = false) const; /** - * @brief Use this method to unpin a message in a supergroup or a channel. - * @param chatId Unique identifier for the target chat. + * @brief Use this method to unpin a message in a group, a supergroup, or a channel. + * @param chatId Unique identifier for the target chat or username of the target channel. * @return True on success */ bool unpinChatMessage(int64_t chatId) const; @@ -792,7 +793,6 @@ public: std::vector getGameHighScores(int32_t userId, int32_t score, bool force = false, bool disableEditMessage = false, int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "") const; - /** * @brief Downloads file from Telegram and saves it in memory. * @param filePath Telegram file path. @@ -801,6 +801,33 @@ public: */ std::string downloadFile(const std::string& filePath, const std::vector& args = std::vector()) const; + /** + * @brief Use this method to send a poll. + * @param chatId Unique identifier for the target chat or username of the target channel. + * @param question Poll question, 1-255 characters. + * @param options List of answer options, 2-10 strings 1-100 characters each. + * @param disable_notification Optional. Sends the message silenty. + * @param reply_to_message_id Optional. If the message is a reply, ID of the original message. + * @param reply_markup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * + * @return On success, the sent message is returned. + */ + Message::Ptr sendPoll(int64_t chatId, std::string question, std::vector options, bool disable_notification=false, int32_t reply_to_message_id=0,GenericReply::Ptr reply_markup = std::make_shared()) const; + + /** + * @brief Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned.. + * @param chatId Unique identifier for the target chat or username of the target channel. + * @param question Poll question, 1-255 characters. + * @param options List of answer options, 2-10 strings 1-100 characters each. + * @param disable_notification Optional. Sends the message silenty. + * @param reply_to_message_id Optional. If the message is a reply, ID of the original message. + * @param reply_markup Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. + * + * @return On success, the sent message is returned. + */ + + Poll::Ptr stopPoll(int64_t chatId, int64_t messageId, InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared()) const; + private: boost::property_tree::ptree sendRequest(const std::string& method, const std::vector& args = std::vector()) const; diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index eeda4cd..a2cb660 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -36,6 +36,8 @@ #include "tgbot/types/Document.h" #include "tgbot/types/Sticker.h" #include "tgbot/types/StickerSet.h" +#include "tgbot/types/Poll.h" +#include "tgbot/types/PollOption.h" #include "tgbot/types/MaskPosition.h" #include "tgbot/types/Video.h" #include "tgbot/types/Voice.h" @@ -145,6 +147,12 @@ namespace TgBot { MaskPosition::Ptr parseJsonAndGetMaskPosition(const boost::property_tree::ptree& data) const; std::string parseMaskPosition(const MaskPosition::Ptr& object) const; + Poll::Ptr parseJsonAndGetPoll(const boost::property_tree::ptree& data) const; + std::string parsePoll(const Poll::Ptr& object) const; + + PollOption::Ptr parseJsonAndGetPollOption(const boost::property_tree::ptree& data) const; + std::string parsePollOption(const PollOption::Ptr& object) const; + Video::Ptr parseJsonAndGetVideo(const boost::property_tree::ptree& data) const; std::string parseVideo(const Video::Ptr& object) const; diff --git a/include/tgbot/types/ChatMember.h b/include/tgbot/types/ChatMember.h index facfec2..79fff0e 100644 --- a/include/tgbot/types/ChatMember.h +++ b/include/tgbot/types/ChatMember.h @@ -76,6 +76,11 @@ public: */ bool canPinMessages = false; + /** + * @brief Optional. Restricted only. True, if the user is a member of the chat at the moment of the request. + */ + bool isMember = false; + /** * @brief Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user). */ diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h index f92eeaf..4b7ce59 100644 --- a/include/tgbot/types/Message.h +++ b/include/tgbot/types/Message.h @@ -34,6 +34,7 @@ #include "tgbot/types/Document.h" #include "tgbot/types/Animation.h" #include "tgbot/types/Sticker.h" +#include "tgbot/types/Poll.h" #include "tgbot/types/Video.h" #include "tgbot/types/Contact.h" #include "tgbot/types/Location.h" @@ -96,6 +97,11 @@ public: */ std::string forwardSignature; + /** + * @brief Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages. + */ + std::string forwardSenderName; + /** * @brief Optional. For forwarded messages, date the original message was sent in Unix time. */ @@ -193,6 +199,11 @@ public: */ Venue::Ptr venue; + /** + * @brief Optional. Message is a poll, information about the poll. + */ + Poll::Ptr poll; + /** * @brief Optional. A new member was added to the group, information about them (this member may be bot itself). */ diff --git a/include/tgbot/types/Poll.h b/include/tgbot/types/Poll.h new file mode 100644 index 0000000..11c3c07 --- /dev/null +++ b/include/tgbot/types/Poll.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019 Nitan Alexandru Marcel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef TGBOT_POLL_H +#define TGBOT_POLL_H + +#include +#include +#include +#include "tgbot/types/PollOption.h" + +namespace TgBot{ + /** + * @brief This object represents a Poll. + * + * @ingroup types + */ + class Poll{ + public: + typedef std::shared_ptr Ptr; + + /** + * @brief Unique poll identifier. + */ + int64_t id; + + /** + * @brief Poll question, 1-255 characters. + */ + std::string question; + + /** + * @brief List of poll options. + */ + PollOption::Ptr options; + + /** + * @brief True, if the poll is closed. + */ + bool is_closed; + }; +} + +#endif //TGBOT_POLL_H diff --git a/include/tgbot/types/PollOption.h b/include/tgbot/types/PollOption.h new file mode 100644 index 0000000..52099f9 --- /dev/null +++ b/include/tgbot/types/PollOption.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019 Nitan Alexandru Marcel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include + +#ifndef TGBOT_POLLOPTION_H +#define TGBOT_POLLOPTION_H + +class PollOption { + +public: + typedef std::shared_ptr Ptr; + + /** + * @brief Option text, 1-100 characters. + */ + std::string text; + + /** + * @brief Number of users that voted for this option. + */ + int64_t voter_count; +}; + +#endif //TGBOT_POLLOPTION_H -- cgit v1.2.3 From eb10c8705be495cc9d663dd48672eb9e174f0e4c Mon Sep 17 00:00:00 2001 From: nitanmarcel Date: Tue, 19 Nov 2019 21:59:22 +0200 Subject: API 4.3 --- include/tgbot/types/InlineKeyboardButton.h | 6 ++++ include/tgbot/types/LoginUrl.h | 45 ++++++++++++++++++++++++++++++ include/tgbot/types/Message.h | 6 ++++ 3 files changed, 57 insertions(+) create mode 100644 include/tgbot/types/LoginUrl.h (limited to 'include') diff --git a/include/tgbot/types/InlineKeyboardButton.h b/include/tgbot/types/InlineKeyboardButton.h index 4b83087..f02d788 100644 --- a/include/tgbot/types/InlineKeyboardButton.h +++ b/include/tgbot/types/InlineKeyboardButton.h @@ -9,6 +9,7 @@ #include #include "tgbot/types/CallbackGame.h" +#include "tgbot/types/LoginUrl.h" namespace TgBot { @@ -31,6 +32,11 @@ public: */ std::string url; + /** + * @brief Optional. An HTTP URL used to automatically authorize the user. + */ + LoginUrl::Ptr loginUrl; + /** * @brief Optional. Data to be sent in a callback query to the bot when button is pressed. */ diff --git a/include/tgbot/types/LoginUrl.h b/include/tgbot/types/LoginUrl.h new file mode 100644 index 0000000..1627399 --- /dev/null +++ b/include/tgbot/types/LoginUrl.h @@ -0,0 +1,45 @@ +// +// Created by alexandrumarcel on 19.11.2019. +// + +#ifndef TGBOT_CPP_LOGINURL_H +#define TGBOT_CPP_LOGINURL_H + +#include +#include +#include + + +namespace TgBot{ + /** + * @brief This object represents a Poll. + * + * @ingroup types + */ + class LoginUrl{ + public: + typedef std::shared_ptr Ptr; + + /** + * @brief UAn HTTP URL to be opened with user authorization data added to the query string when the button is pressed.. + */ + std::string url; + + /** + * @brief Optional. New text of the button in forwarded messages. + */ + std::string forward_text; + + /** + * @brief Optional. Username of a bot, which will be used for user authorization. + */ + std::string bot_username; + + /** + * @brief Optional. Pass True to request the permission for your bot to send messages to the user. + */ + bool request_write_access; + }; +} + +#endif //TGBOT_CPP_LOGINURL_H diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h index 4b7ce59..9e831bc 100644 --- a/include/tgbot/types/Message.h +++ b/include/tgbot/types/Message.h @@ -45,6 +45,7 @@ #include "tgbot/types/Voice.h" #include "tgbot/types/Invoice.h" #include "tgbot/types/SuccessfulPayment.h" +#include "tgbot/types/InlineKeyboardMarkup.h" namespace TgBot { @@ -278,6 +279,11 @@ public: * @brief Optional. The domain name of the website on which the user has logged in. */ std::string connectedWebsite; + + /** + * @brief Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. + */ + InlineKeyboardMarkup::Ptr replyMarkup; }; } -- cgit v1.2.3 From 084a6492103eff0d021562694c6869fdcce58261 Mon Sep 17 00:00:00 2001 From: nitanmarcel Date: Wed, 20 Nov 2019 21:04:11 +0200 Subject: API 4.4 --- include/tgbot/Api.h | 11 ++++- include/tgbot/TgTypeParser.h | 4 ++ include/tgbot/types/Chat.h | 7 +++ include/tgbot/types/ChatMember.h | 5 ++ include/tgbot/types/ChatPermissions.h | 86 +++++++++++++++++++++++++++++++++++ include/tgbot/types/Sticker.h | 5 ++ include/tgbot/types/StickerSet.h | 5 ++ 7 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 include/tgbot/types/ChatPermissions.h (limited to 'include') diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 184f3a1..4ce8dd7 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -679,8 +679,7 @@ public: * @param canAddWebPagePreviews Optional. Pass True, if the user may add web page previews to their messages, implies can_send_media_messages. * @return True on success */ - bool restrictChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0, bool canSendMessages = false, - bool canSendMediaMessages = false, bool canSendOtherMessages = false, bool canAddWebPagePreviews = false) const; + bool restrictChatMember(int64_t chatId, int32_t userId, ChatPermissions::Ptr permissions, uint64_t untilDate = 0) const; /** * @brief Use this method to promote or demote a user in a supergroup or a channel. @@ -699,6 +698,14 @@ public: bool promoteChatMember(int64_t chatId, int32_t userId, bool canChangeInfo = false, bool canPostMessages = false, bool canEditMessages = false, bool canDeleteMessages = false, bool canInviteUsers = false, bool canPinMessages = false, bool canPromoteMembers = false) const; + /** + * @brief Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights. Returns True on success. + * @param chatId Unique identifier for the target chat of the target supergroup. + * @param permissions New default chat permissions. + * @return True on success + */ + bool setChatPermissions(int64_t chatId, ChatPermissions::Ptr permissions) const; + /** * @brief Use this method to generate a new invite link for a chat; any previously generated link is revoked. * @param chatId Unique identifier for the target chat. diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index a2cb660..aa0cd10 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -38,6 +38,7 @@ #include "tgbot/types/StickerSet.h" #include "tgbot/types/Poll.h" #include "tgbot/types/PollOption.h" +#include "tgbot/types/ChatPermissions.h" #include "tgbot/types/MaskPosition.h" #include "tgbot/types/Video.h" #include "tgbot/types/Voice.h" @@ -153,6 +154,9 @@ namespace TgBot { PollOption::Ptr parseJsonAndGetPollOption(const boost::property_tree::ptree& data) const; std::string parsePollOption(const PollOption::Ptr& object) const; + ChatPermissions::Ptr parseJsonAndGetChatPermissions(const boost::property_tree::ptree& data) const; + std::string parseChatPermissions(const ChatPermissions::Ptr& object) const; + Video::Ptr parseJsonAndGetVideo(const boost::property_tree::ptree& data) const; std::string parseVideo(const Video::Ptr& object) const; diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h index a402ebb..eb38ec7 100644 --- a/include/tgbot/types/Chat.h +++ b/include/tgbot/types/Chat.h @@ -27,6 +27,7 @@ #include #include "tgbot/types/ChatPhoto.h" +#include "tgbot/types/ChatPermissions.h" namespace TgBot { @@ -110,6 +111,12 @@ public: */ std::shared_ptr pinnedMessage; + /** + * @brief Optional. Default chat member permissions, for groups and supergroups. + * Returned only in getChat. + */ + ChatPermissions::Ptr permissions; + /** * @brief Optional. For supergroups, name of group sticker set. * Returned only in getChat. diff --git a/include/tgbot/types/ChatMember.h b/include/tgbot/types/ChatMember.h index 79fff0e..f5e5acd 100644 --- a/include/tgbot/types/ChatMember.h +++ b/include/tgbot/types/ChatMember.h @@ -101,6 +101,11 @@ public: */ bool canSendOtherMessages = false; + /** + * @brief Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages. + */ + bool canSendPolls = false; + /** * @brief Optional. Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages. */ diff --git a/include/tgbot/types/ChatPermissions.h b/include/tgbot/types/ChatPermissions.h new file mode 100644 index 0000000..8db32e6 --- /dev/null +++ b/include/tgbot/types/ChatPermissions.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2019 Marcel Alexandru + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef TGBOT_CPP_CHATPERMISSIONS_H +#define TGBOT_CPP_CHATPERMISSIONS_H + +#include +#include + + +namespace TgBot { + + /** + * @brief This object describes actions that a non-administrator user is allowed to take in a chat. + * @ingroup types + */ + + class ChatPermissions { + public: + typedef std::shared_ptr Ptr; + + /** + * @brief Optional. True, if the user is allowed to send text messages, contacts, locations and venues. + */ + bool canSendMessages = false; + + /** + * @brief Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages. + */ + bool canSendMediaMessages = false; + + /** + * @brief Optional. True, if the user is allowed to send polls, implies can_send_messages. + */ + bool canSendPolls = false; + + /** + * @brief Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages. + */ + bool canSendOtherMessages = false; + + /** + * @brief Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages. + */ + bool canAddWebPagePreviews = false; + + /** + * @brief Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups. + */ + bool canChangeInfo = false; + + /** + * @brief Optional. True, if the user is allowed to invite new users to the chat. + */ + bool canInviteUsers = false; + + /** + * @brief Optional. True, if the user is allowed to pin messages. Ignored in public supergroups. + */ + bool canPinMessages = false; + + + + }; +} + +#endif //TGBOT_CPP_CHATPERMISSIONS_H diff --git a/include/tgbot/types/Sticker.h b/include/tgbot/types/Sticker.h index 9fd200a..68fc574 100644 --- a/include/tgbot/types/Sticker.h +++ b/include/tgbot/types/Sticker.h @@ -56,6 +56,11 @@ public: */ int32_t height; + /** + * @brief True, if the sticker is animated. + */ + bool isAnimated = false; + /** * @brief Optional. Optional. Sticker thumbnail in .webp or .jpg format. */ diff --git a/include/tgbot/types/StickerSet.h b/include/tgbot/types/StickerSet.h index d08fd4a..deddf74 100644 --- a/include/tgbot/types/StickerSet.h +++ b/include/tgbot/types/StickerSet.h @@ -51,6 +51,11 @@ public: */ std::string title; + /** + * @brief True, if the sticker set contains animated stickers. + */ + bool isAnimated = false; + /** * @brief True, if the sticker set contains masks. */ -- cgit v1.2.3 From e1031f20f9139a554c3e4cf70585ae0dcea1bcda Mon Sep 17 00:00:00 2001 From: Oleg Morozenkov Date: Thu, 5 Dec 2019 00:59:41 +0300 Subject: Apply @JellyBrick fixes --- include/tgbot/types/InlineKeyboardButton.h | 4 ++-- include/tgbot/types/Poll.h | 4 ++-- include/tgbot/types/PollOption.h | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/tgbot/types/InlineKeyboardButton.h b/include/tgbot/types/InlineKeyboardButton.h index f02d788..f274825 100644 --- a/include/tgbot/types/InlineKeyboardButton.h +++ b/include/tgbot/types/InlineKeyboardButton.h @@ -33,8 +33,8 @@ public: std::string url; /** - * @brief Optional. An HTTP URL used to automatically authorize the user. - */ + * @brief Optional. An HTTP URL used to automatically authorize the user. + */ LoginUrl::Ptr loginUrl; /** diff --git a/include/tgbot/types/Poll.h b/include/tgbot/types/Poll.h index 11c3c07..e218997 100644 --- a/include/tgbot/types/Poll.h +++ b/include/tgbot/types/Poll.h @@ -28,13 +28,13 @@ #include #include "tgbot/types/PollOption.h" -namespace TgBot{ +namespace TgBot { /** * @brief This object represents a Poll. * * @ingroup types */ - class Poll{ + class Poll { public: typedef std::shared_ptr Ptr; diff --git a/include/tgbot/types/PollOption.h b/include/tgbot/types/PollOption.h index 52099f9..0d87870 100644 --- a/include/tgbot/types/PollOption.h +++ b/include/tgbot/types/PollOption.h @@ -27,6 +27,8 @@ #ifndef TGBOT_POLLOPTION_H #define TGBOT_POLLOPTION_H +namespace TgBot { + class PollOption { public: @@ -43,4 +45,6 @@ public: int64_t voter_count; }; +} + #endif //TGBOT_POLLOPTION_H -- cgit v1.2.3