diff options
author | JellyBrick <shlee1503@naver.com> | 2018-05-28 02:27:25 +0900 |
---|---|---|
committer | JellyBrick <shlee1503@naver.com> | 2018-05-28 02:27:25 +0900 |
commit | b0134ff90ccd4203721fd8d32c1d1bacaea8b47f (patch) | |
tree | a0fc5b5bfd08e9396409cb908818fd79eceec6f2 | |
parent | 6d365b8b555e7d1f6b32ba8b87bea8a593021cc2 (diff) |
Bot API 3.4 update
-rw-r--r-- | include/tgbot/Api.h | 46 | ||||
-rw-r--r-- | include/tgbot/types/Message.h | 5 | ||||
-rw-r--r-- | src/Api.cpp | 54 | ||||
-rw-r--r-- | src/TgTypeParser.cpp | 1 |
4 files changed, 103 insertions, 3 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index 7a82072..6e48207 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -376,13 +376,39 @@ public: * @param chatId Unique identifier for the target chat. * @param latitude Latitude of location. * @param longitude Longitude of location. + * @param livePeriod Optional. Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400). * @param replyToMessageId Optional. If the message is a reply, ID of the original message. * @param replyMarkup Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. * @param disableNotification Optional. Sends the message silenty. * @return On success, the sent message is returned. */ - Message::Ptr sendLocation(int64_t chatId, float latitude, float longitude, int32_t replyToMessageId = 0, - const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const; + Message::Ptr sendLocation(int64_t chatId, float latitude, float longitude, uint32_t livePeriod = 0, + int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const; + + /** + * Use this method to edit live location messages sent by the bot or via the bot (for inline bots). + * @param latitude Latitude of new location. + * @param longitude Longitude of new location. + * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel (in the format @channelusername). + * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message. + * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message. + * @param replyMarkup Optional. A JSON-serialized object for a new inline keyboard. + * @return On success, if the edited message was sent by the bot, the edited Message is returned, otherwise nullptr is returned. + */ + Message::Ptr editMessageLiveLocation(float latitude, float longitude, int64_t chatId = 0, int32_t messageId = 0, + int32_t inlineMessageId = 0, const InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>()) const; + + /** + * Use this method to edit live location messages sent by the bot or via the bot (for inline bots). + * @param chatId Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel (in the format @channelusername). + * @param messageId Optional. Required if inlineMessageId is not specified. Identifier of the sent message. + * @param inlineMessageId Optional. Required if chatId and messageId are not specified. Identifier of the inline message. + * @param replyMarkup Optional. A JSON-serialized object for a new inline keyboard. + * @return On success, if the edited message was sent by the bot, the edited Message is returned, otherwise nullptr is returned. + */ + Message::Ptr stopMessageLiveLocation(int64_t chatId = 0, int32_t messageId = 0, int32_t inlineMessageId = 0, + const InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>()) const; + /** * Use this method to send information about a venue. On success, the sent Message is returned. @@ -476,6 +502,22 @@ public: ChatMember::Ptr getChatMember(int64_t chatId, int32_t userId) const; /** + * Use this method to get information about a member of a chat. Returns a ChatMember object on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) + * @param stickerSetName Name of the sticker set to be set as the group sticker set. + * @return Returns True on success. + */ + bool setChatStickerSet(int64_t chatId, const std::string& stickerSetName) const; + + /** + * Use this method to get information about a member of a chat. Returns a ChatMember object on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) + * @return Returns True on success. + */ + bool deleteChatStickerSet(int64_t chatId) const; + + + /** * Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. * @param callbackQueryId Unique identifier for the query to be answered * @param text Optional Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h index b988c08..fbfbf15 100644 --- a/include/tgbot/types/Message.h +++ b/include/tgbot/types/Message.h @@ -131,6 +131,11 @@ public: std::vector<MessageEntity::Ptr> entities; /** + * Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption + */ + std::vector<MessageEntity::Ptr> captionEntities; + + /** * Optional. Message is an audio file, information about the file. */ Audio::Ptr audio; diff --git a/src/Api.cpp b/src/Api.cpp index 91bab0d..cb33058 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -451,11 +451,14 @@ Message::Ptr Api::sendVoice(int64_t chatId, const string& voiceId, const string return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendVoice", args)); } -Message::Ptr Api::sendLocation(int64_t chatId, float latitude, float longitude, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const { +Message::Ptr Api::sendLocation(int64_t chatId, float latitude, float longitude, uint32_t livePeriod, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const { vector<HttpReqArg> args; args.push_back(HttpReqArg("chat_id", chatId)); args.push_back(HttpReqArg("latitude", latitude)); args.push_back(HttpReqArg("longitude", longitude)); + if (livePeriod) { + args.push_back(HttpReqArg("live_period", livePeriod)); + } if (replyToMessageId) { args.push_back(HttpReqArg("reply_to_message_id", replyToMessageId)); } @@ -468,6 +471,55 @@ Message::Ptr Api::sendLocation(int64_t chatId, float latitude, float longitude, return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendLocation", args)); } +Message::Ptr Api::editMessageLiveLocation(float latitude, float longitude, int64_t chatId, int32_t messageId, int32_t inlineMessageId, const InlineKeyboardMarkup::Ptr replyMarkup) const { + vector<HttpReqArg> args; + args.push_back(HttpReqArg("latitude", latitude)); + args.push_back(HttpReqArg("longitude", longitude)); + if (chatId) { + args.push_back(HttpReqArg("chat_id", chatId)); + } + if (messageId) { + args.push_back(HttpReqArg("message_id", messageId)); + } + if (inlineMessageId) { + args.push_back(HttpReqArg("inline_message_id", inlineMessageId)); + } + if (replyMarkup) { + args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseInlineKeyboardMarkup(replyMarkup))); + } + return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("editMessageLiveLocation", args)); +} + +Message::Ptr Api::editMessageLiveLocation(int64_t chatId, int32_t messageId, int32_t inlineMessageId, const InlineKeyboardMarkup::Ptr replyMarkup) const { + vector<HttpReqArg> args; + if (chatId) { + args.push_back(HttpReqArg("chat_id", chatId)); + } + if (messageId) { + args.push_back(HttpReqArg("message_id", messageId)); + } + if (inlineMessageId) { + args.push_back(HttpReqArg("inline_message_id", inlineMessageId)); + } + if (replyMarkup) { + args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseInlineKeyboardMarkup(replyMarkup))); + } + return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("editMessageLiveLocation", args)); +} + +bool Api::setChatStickerSet(int64_t chatId, const string& stickerSetName) const { + vector<HttpReqArg> args; + args.push_back(HttpReqArg("chat_id", chatId)); + args.push_back(HttpReqArg("sticker_set_name ", stickerSetName)); + return sendRequest("setChatStickerSet", args).get<bool>("", false); +} + +bool Api::deleteChatStickerSet(int64_t chatId) const { + vector<HttpReqArg> args; + args.push_back(HttpReqArg("chat_id", chatId)); + return sendRequest("deleteChatStickerSet", args).get<bool>("", false); +} + Message::Ptr Api::sendVenue(int64_t chatId, float latitude, float longitude, const string& title, const string& address, const string& foursquareId, bool disableNotification, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const { vector<HttpReqArg> args; args.push_back(HttpReqArg("chat_id", chatId)); diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index 46760fc..702bc71 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -139,6 +139,7 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const { result->authorSignature = data.get("author_signature", ""); result->text = data.get("text", ""); result->entities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetEntity, data, "entities"); + result->captionEntities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetEntity, data, "caption_entities"); result->audio = tryParseJson<Audio>(&TgTypeParser::parseJsonAndGetAudio, data, "audio"); result->document = tryParseJson<Document>(&TgTypeParser::parseJsonAndGetDocument, data, "document"); result->photo = parseJsonAndGetArray<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "photo"); |