summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJellyBrick <shlee1503@naver.com>2018-05-27 17:50:32 +0900
committerJellyBrick <shlee1503@naver.com>2018-05-27 17:50:32 +0900
commitc81f7d9d7a4fe9dc3b48b92fad633bd5c44b8e74 (patch)
treeda38554686741def766773e1068979fb8102fc6f
parent8206df62f7f9540a2f13ce31c85f8a1f2054bd56 (diff)
Bot API 3.3 update
-rw-r--r--include/tgbot/types/Chat.h2
-rw-r--r--include/tgbot/types/Message.h12
-rw-r--r--include/tgbot/types/User.h5
-rw-r--r--src/TgTypeParser.cpp8
4 files changed, 24 insertions, 3 deletions
diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h
index c5c397f..978d2c4 100644
--- a/include/tgbot/types/Chat.h
+++ b/include/tgbot/types/Chat.h
@@ -108,7 +108,7 @@ public:
* Optional. Pinned message, for supergroups and channel chats.
* Returned only in getChat.
*/
- Message::Ptr pinnedMessage;
+ std::shared_ptr<Message> pinnedMessage;
/**
* Optional. For supergroups, name of group sticker set.
diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h
index ee293b9..b988c08 100644
--- a/include/tgbot/types/Message.h
+++ b/include/tgbot/types/Message.h
@@ -96,6 +96,11 @@ public:
int32_t forwardFromMessageId;
/**
+ * Optional. For messages forwarded from channels, signature of the post author if present.
+ */
+ std::string forwardSignature;
+
+ /**
* Optional. For forwarded messages, date the original message was sent in Unix time.
*/
int32_t forwardDate;
@@ -106,11 +111,16 @@ public:
Message::Ptr replyToMessage;
/**
- * Optional. Date the message was last edited in Unix time
+ * Optional. Date the message was last edited in Unix time.
*/
int32_t editDate;
/**
+ * Optional. Signature of the post author for messages in channels.
+ */
+ std::string authorSignature;
+
+ /**
* Optional. For text messages, the actual UTF-8 text of the message.
*/
std::string text;
diff --git a/include/tgbot/types/User.h b/include/tgbot/types/User.h
index f3a6960..7ee7da6 100644
--- a/include/tgbot/types/User.h
+++ b/include/tgbot/types/User.h
@@ -43,6 +43,11 @@ public:
int32_t id;
/**
+ * True, if this user is a bot
+ */
+ bool isBot = false;
+
+ /**
* User‘s or bot’s first name.
*/
std::string firstName;
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index 0facf93..fafe94f 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -47,7 +47,7 @@ Chat::Ptr TgTypeParser::parseJsonAndGetChat(const ptree& data) const {
}
result->title = data.get("title", "");
result->username = data.get("username", "");
- result->firstName = data.get<string>("first_name", "");
+ result->firstName = data.get("first_name", "");
result->lastName = data.get("last_name", "");
result->allMembersAreAdministrators = data.get<bool>("all_members_are_administrators", false);
result->photo = tryParseJson<ChatPhoto>(&TgTypeParser::parseJsonAndGetChatPhoto, data, "photo");
@@ -88,6 +88,7 @@ string TgTypeParser::parseChat(const Chat::Ptr& object) const {
User::Ptr TgTypeParser::parseJsonAndGetUser(const ptree& data) const {
auto result(make_shared<User>());
result->id = data.get<int32_t>("id");
+ result->isBot = data.get<bool>("is_bot", false);
result->firstName = data.get<string>("first_name");
result->lastName = data.get("last_name", "");
result->username = data.get("username", "");
@@ -102,6 +103,7 @@ string TgTypeParser::parseUser(const User::Ptr& object) const {
string result;
result += '{';
appendToJson(result, "id", object->id);
+ appendToJson(result, "is_bot", object->isBot);
appendToJson(result, "first_name", object->firstName);
appendToJson(result, "last_name", object->lastName);
appendToJson(result, "username", object->username);
@@ -130,9 +132,11 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
result->forwardFrom = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "forward_from");
result->forwardFromChat = tryParseJson<Chat>(&TgTypeParser::parseJsonAndGetChat, data, "forward_from_chat");
result->forwardFromMessageId = data.get<int32_t>("forward_from_message_id", 0);
+ result->forwardSignature = data.get("forward_signature", "");
result->forwardDate = data.get("forward_date", 0);
result->replyToMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "reply_to_message");
result->editDate = data.get<int32_t>("edit_date", 0);
+ result->authorSignature = data.get("author_signature", "");
result->text = data.get("text", "");
result->entities = parseJsonAndGetArray<MessageEntity>(&TgTypeParser::parseJsonAndGetEntity, data, "entities");
result->audio = tryParseJson<Audio>(&TgTypeParser::parseJsonAndGetAudio, data, "audio");
@@ -170,9 +174,11 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const {
appendToJson(result, "forward_from", parseUser(object->forwardFrom));
appendToJson(result, "forward_from_chat", parseChat(object->forwardFromChat));
appendToJson(result, "forward_from_message_id", object->forwardFromMessageId);
+ appendToJson(result, "forward_signature", object->forwardSignature);
appendToJson(result, "forward_date", object->forwardDate);
appendToJson(result, "reply_to_message", parseMessage(object->replyToMessage));
appendToJson(result, "edit_date", object->editDate);
+ appendToJson(result, "author_signature", object->authorSignature);
appendToJson(result, "text", object->text);
appendToJson(result, "audio", parseAudio(object->audio));
appendToJson(result, "document", parseDocument(object->document));