summaryrefslogtreecommitdiff
path: root/include/tgbot
diff options
context:
space:
mode:
authorOleg Morozenkov <omorozenkov@gmail.com>2015-11-23 14:44:20 +0300
committerOleg Morozenkov <omorozenkov@gmail.com>2015-11-23 14:44:20 +0300
commit6fd3160feba7dc1228221ff4c8626cad48406d06 (patch)
tree186bd84429f9af6f5406d5a04a6fc339116f3c17 /include/tgbot
parent3040a62a71050e53624583bd83b3bffeb6aca9f0 (diff)
parent03a1a5b66037df5df46a7beba980a4931f38f1a3 (diff)
Merge pull request #8 from naveenvhegde/master
Add Chat class ( instead of user or group).
Diffstat (limited to 'include/tgbot')
-rw-r--r--include/tgbot/TgTypeParser.h3
-rw-r--r--include/tgbot/types/Chat.h75
-rw-r--r--include/tgbot/types/Message.h5
3 files changed, 81 insertions, 2 deletions
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index 07eb1b6..2da9685 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -29,6 +29,7 @@
#include <boost/property_tree/json_parser.hpp>
#include "tgbot/types/User.h"
+#include "tgbot/types/Chat.h"
#include "tgbot/types/GroupChat.h"
#include "tgbot/types/Message.h"
#include "tgbot/types/PhotoSize.h"
@@ -58,6 +59,8 @@ public:
static TgTypeParser& getInstance();
+ 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;
GroupChat::Ptr parseJsonAndGetGroupChat(const boost::property_tree::ptree& data) const;
diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h
new file mode 100644
index 0000000..d05155c
--- /dev/null
+++ b/include/tgbot/types/Chat.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2015 Oleg Morozenkov
+ *
+ * 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_CHAT_H
+#define TGBOT_CPP_CHAT_H
+
+#include <string>
+#include <memory>
+
+#include "tgbot/types/GenericChat.h"
+
+namespace TgBot {
+
+/**
+ * This object represents a Telegram Chat
+ * @ingroup types
+ */
+class Chat : public GenericChat {
+
+public:
+ typedef std::shared_ptr<Chat> Ptr;
+
+ /**
+ * Type of chat : can be either
+ * "private", "group", "supergroup,
+ * or "channel"
+ */
+ std::string type;
+
+ /**
+ * Optional. Title for channels and group chat
+ */
+ std::string title;
+
+ /**
+ * Optional. Username for
+ * private chats and channels
+ */
+ std::string username;
+
+ /**
+ * Optional. First name of the
+ * other party in private chat
+ */
+ std::string firstName;
+
+ /**
+ * Optional. Last name of the
+ * other party in private chat
+ */
+ std::string lastName;
+};
+
+}
+
+#endif //TGBOT_CPP_CHAT_H
diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h
index b8dfcc6..4185052 100644
--- a/include/tgbot/types/Message.h
+++ b/include/tgbot/types/Message.h
@@ -27,6 +27,7 @@
#include <vector>
#include <memory>
+#include "tgbot/types/Chat.h"
#include "tgbot/types/User.h"
#include "tgbot/types/GenericChat.h"
#include "tgbot/types/Message.h"
@@ -65,9 +66,9 @@ public:
int32_t date;
/**
- * Conversation the message belongs to — user in case of a private message, GroupChat in case of a group.
+ * Chat.
*/
- GenericChat::Ptr chat;
+ Chat::Ptr chat;
/**
* Optional. For forwarded messages, sender of the original message.