summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJellyBrick <shlee1503@naver.com>2018-05-28 19:39:17 +0900
committerJellyBrick <shlee1503@naver.com>2018-05-28 19:39:17 +0900
commit955e70900a847f79b632a65c850b510b737a2a2a (patch)
tree4d9b11968d7a65d930b638fb54f39cfd005804a0 /src
parentce9bcf9d653a0598b41fcf52708d01b396c6fd30 (diff)
Bot API 3.6 update
Diffstat (limited to 'src')
-rw-r--r--src/Api.cpp56
-rw-r--r--src/TgTypeParser.cpp4
2 files changed, 50 insertions, 10 deletions
diff --git a/src/Api.cpp b/src/Api.cpp
index ca2f969..269b8a6 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -71,7 +71,7 @@ Message::Ptr Api::forwardMessage(int64_t chatId, int64_t fromChatId, int32_t mes
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("forwardMessage", args));
}
-Message::Ptr Api::sendPhoto(int64_t chatId, const InputFile::Ptr photo, const string& caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendPhoto(int64_t chatId, const InputFile::Ptr photo, const string& caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("photo", photo->data, true, photo->mimeType, photo->fileName));
@@ -84,13 +84,16 @@ Message::Ptr Api::sendPhoto(int64_t chatId, const InputFile::Ptr photo, const st
if (replyMarkup) {
args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
}
+ if (!parseMode.empty()) {
+ args.push_back(HttpReqArg("parse_mode", parseMode));
+ }
if (disableNotification){
args.push_back(HttpReqArg("disable_notification", disableNotification));
}
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendPhoto", args));
}
-Message::Ptr Api::sendPhoto(int64_t chatId, const string& photoId, const string& caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendPhoto(int64_t chatId, const string& photoId, const string& caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("photo", photoId));
@@ -103,13 +106,16 @@ Message::Ptr Api::sendPhoto(int64_t chatId, const string& photoId, const string&
if (replyMarkup) {
args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
}
+ if (!parseMode.empty()) {
+ args.push_back(HttpReqArg("parse_mode", parseMode));
+ }
if (disableNotification){
args.push_back(HttpReqArg("disable_notification", disableNotification));
}
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendPhoto", args));
}
-Message::Ptr Api::sendAudio(int64_t chatId, const InputFile::Ptr audio, const string &caption, int32_t duration, const string& performer, const string& title, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendAudio(int64_t chatId, const InputFile::Ptr audio, const string &caption, int32_t duration, const string& performer, const string& title, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("audio", audio->data, true, audio->mimeType, audio->fileName));
@@ -131,13 +137,16 @@ Message::Ptr Api::sendAudio(int64_t chatId, const InputFile::Ptr audio, const st
if (replyMarkup) {
args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
}
+ if (!parseMode.empty()) {
+ args.push_back(HttpReqArg("parse_mode", parseMode));
+ }
if (disableNotification){
args.push_back(HttpReqArg("disable_notification", disableNotification));
}
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendAudio", args));
}
-Message::Ptr Api::sendAudio(int64_t chatId, const string& audioId, const string &caption, int32_t duration, const string& performer, const string& title, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendAudio(int64_t chatId, const string& audioId, const string &caption, int32_t duration, const string& performer, const string& title, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("audio", audioId));
@@ -159,13 +168,16 @@ Message::Ptr Api::sendAudio(int64_t chatId, const string& audioId, const string
if (replyMarkup) {
args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
}
+ if (!parseMode.empty()) {
+ args.push_back(HttpReqArg("parse_mode", parseMode));
+ }
if (disableNotification){
args.push_back(HttpReqArg("disable_notification", disableNotification));
}
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendAudio", args));
}
-Message::Ptr Api::sendDocument(int64_t chatId, const InputFile::Ptr document, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendDocument(int64_t chatId, const InputFile::Ptr document, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("document", document->data, true, document->mimeType, document->fileName));
@@ -178,13 +190,16 @@ Message::Ptr Api::sendDocument(int64_t chatId, const InputFile::Ptr document, co
if (replyMarkup) {
args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
}
+ if (!parseMode.empty()) {
+ args.push_back(HttpReqArg("parse_mode", parseMode));
+ }
if (disableNotification){
args.push_back(HttpReqArg("disable_notification", disableNotification));
}
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendDocument", args));
}
-Message::Ptr Api::sendDocument(int64_t chatId, const string& document, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendDocument(int64_t chatId, const string& document, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("document", document));
@@ -197,6 +212,9 @@ Message::Ptr Api::sendDocument(int64_t chatId, const string& document, const str
if (replyMarkup) {
args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
}
+ if (!parseMode.empty()) {
+ args.push_back(HttpReqArg("parse_mode", parseMode));
+ }
if (disableNotification){
args.push_back(HttpReqArg("disable_notification", disableNotification));
}
@@ -307,10 +325,13 @@ bool Api::deleteStickerPositionInSet(const string& sticker) const {
return sendRequest("setStickerPositionInSet", args).get<bool>("", false);
}
-Message::Ptr Api::sendVideo(int64_t chatId, const InputFile::Ptr video, int32_t duration, int32_t width, int32_t height, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendVideo(int64_t chatId, const InputFile::Ptr video, bool supportsStreaming, int32_t duration, int32_t width, int32_t height, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("video", video->data, true, video->mimeType, video->fileName));
+ if (supportsStreaming) {
+ args.push_back(HttpReqArg("supports_streaming", supportsStreaming));
+ }
if (duration) {
args.push_back(HttpReqArg("duration", duration));
}
@@ -329,16 +350,22 @@ Message::Ptr Api::sendVideo(int64_t chatId, const InputFile::Ptr video, int32_t
if (replyMarkup) {
args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
}
+ if (!parseMode.empty()) {
+ args.push_back(HttpReqArg("parse_mode", parseMode));
+ }
if (disableNotification){
args.push_back(HttpReqArg("disable_notification", disableNotification));
}
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendVideo", args));
}
-Message::Ptr Api::sendVideo(int64_t chatId, const string& videoId, int32_t duration, int32_t width, int32_t height, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendVideo(int64_t chatId, const string& videoId, bool supportsStreaming, int32_t duration, int32_t width, int32_t height, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("video", videoId));
+ if (supportsStreaming) {
+ args.push_back(HttpReqArg("supports_streaming", supportsStreaming));
+ }
if (duration) {
args.push_back(HttpReqArg("duration", duration));
}
@@ -357,6 +384,9 @@ Message::Ptr Api::sendVideo(int64_t chatId, const string& videoId, int32_t durat
if (replyMarkup) {
args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
}
+ if (!parseMode.empty()) {
+ args.push_back(HttpReqArg("parse_mode", parseMode));
+ }
if (disableNotification){
args.push_back(HttpReqArg("disable_notification", disableNotification));
}
@@ -417,7 +447,7 @@ vector<Message::Ptr> Api::sendMediaGroup(int64_t chatId, const vector<InputMedia
return TgTypeParser::getInstance().parseJsonAndGetArray<Message>(&TgTypeParser::parseJsonAndGetMessage, sendRequest("sendMediaGroup", args));
}
-Message::Ptr Api::sendVoice(int64_t chatId, const InputFile::Ptr voice, const string &caption, int duration, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendVoice(int64_t chatId, const InputFile::Ptr voice, const string &caption, int duration, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("voice", voice->data, true, voice->mimeType, voice->fileName));
@@ -433,13 +463,16 @@ Message::Ptr Api::sendVoice(int64_t chatId, const InputFile::Ptr voice, const st
if (replyMarkup) {
args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
}
+ if (!parseMode.empty()) {
+ args.push_back(HttpReqArg("parse_mode", parseMode));
+ }
if (disableNotification){
args.push_back(HttpReqArg("disable_notification", disableNotification));
}
return TgTypeParser::getInstance().parseJsonAndGetMessage(sendRequest("sendVoice", args));
}
-Message::Ptr Api::sendVoice(int64_t chatId, const string& voiceId, const string &caption, int duration, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const {
+Message::Ptr Api::sendVoice(int64_t chatId, const string& voiceId, const string &caption, int duration, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const {
vector<HttpReqArg> args;
args.push_back(HttpReqArg("chat_id", chatId));
args.push_back(HttpReqArg("voice", voiceId));
@@ -455,6 +488,9 @@ Message::Ptr Api::sendVoice(int64_t chatId, const string& voiceId, const string
if (replyMarkup) {
args.push_back(HttpReqArg("reply_markup", TgTypeParser::getInstance().parseGenericReply(replyMarkup)));
}
+ if (!parseMode.empty()) {
+ args.push_back(HttpReqArg("parse_mode", parseMode));
+ }
if (disableNotification){
args.push_back(HttpReqArg("disable_notification", disableNotification));
}
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index f910761..4ba571f 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -159,6 +159,8 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
result->channelChatCreated = data.get("channel_chat_created", false);
result->migrateToChatId = data.get<int64_t>("migrate_to_chat_id", 0);
result->migrateFromChatId = data.get<int64_t>("migrate_from_chat_id", 0);
+ result->pinnedMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "pinned_message");
+ result->connectedWebsite = data.get("connected_website", "");
return result;
}
@@ -200,6 +202,8 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const {
appendToJson(result, "channel_chat_created", object->channelChatCreated);
appendToJson(result, "migrate_to_chat_id", object->migrateToChatId);
appendToJson(result, "migrate_from_chat_id", object->migrateFromChatId);
+ appendToJson(result, "pinned_message", parseMessage(object->pinnedMessage));
+ appendToJson(result, "connected_website", object->connectedWebsite);
result.erase(result.length() - 1);
result += '}';
return result;