summaryrefslogtreecommitdiff
path: root/include/tgbot
diff options
context:
space:
mode:
authorOleg Morozenkov <omorozenkov@gmail.com>2015-07-27 20:59:09 +0300
committerOleg Morozenkov <omorozenkov@gmail.com>2015-07-27 20:59:09 +0300
commit3f7a10f82567a0be04a424e0ddc360a73670c9d7 (patch)
tree4abc86893bbb33298d7058b65a5f94e5d5256c83 /include/tgbot
parente4fb7e904b8d66d502a8e00dd3c9087a98140001 (diff)
Documentation
Diffstat (limited to 'include/tgbot')
-rw-r--r--include/tgbot/Api.h242
-rw-r--r--include/tgbot/Bot.h81
-rw-r--r--include/tgbot/EventBroadcaster.h117
-rw-r--r--include/tgbot/EventHandler.h56
-rw-r--r--include/tgbot/TgException.h43
-rw-r--r--include/tgbot/TgTypeParser.h180
-rw-r--r--include/tgbot/doxygenMain.h89
-rw-r--r--include/tgbot/net/HttpClient.h61
-rw-r--r--include/tgbot/net/HttpParser.h68
-rw-r--r--include/tgbot/net/HttpReqArg.h69
-rw-r--r--include/tgbot/net/HttpServer.h103
-rw-r--r--include/tgbot/net/TgLongPoll.h55
-rw-r--r--include/tgbot/net/TgWebhookLocalServer.h51
-rw-r--r--include/tgbot/net/TgWebhookServer.h57
-rw-r--r--include/tgbot/net/TgWebhookTcpServer.h50
-rw-r--r--include/tgbot/net/Url.h67
-rw-r--r--include/tgbot/tools/StringTools.h91
-rw-r--r--include/tgbot/types/Audio.h63
-rw-r--r--include/tgbot/types/Contact.h63
-rw-r--r--include/tgbot/types/Document.h70
-rw-r--r--include/tgbot/types/ForceReply.h58
-rw-r--r--include/tgbot/types/GenericChat.h49
-rw-r--r--include/tgbot/types/GenericReply.h44
-rw-r--r--include/tgbot/types/GroupChat.h50
-rw-r--r--include/tgbot/types/InputFile.h54
-rw-r--r--include/tgbot/types/Location.h52
-rw-r--r--include/tgbot/types/Message.h165
-rw-r--r--include/tgbot/types/PhotoSize.h63
-rw-r--r--include/tgbot/types/ReplyKeyboardHide.h55
-rw-r--r--include/tgbot/types/ReplyKeyboardMarkup.h67
-rw-r--r--include/tgbot/types/Sticker.h70
-rw-r--r--include/tgbot/types/Update.h54
-rw-r--r--include/tgbot/types/User.h60
-rw-r--r--include/tgbot/types/UserProfilePhotos.h55
-rw-r--r--include/tgbot/types/Video.h80
35 files changed, 2652 insertions, 0 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
new file mode 100644
index 0000000..1b4987a
--- /dev/null
+++ b/include/tgbot/Api.h
@@ -0,0 +1,242 @@
+/*
+ * 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_API_H
+#define TGBOT_CPP_API_H
+
+#include <string>
+#include <vector>
+
+#include <boost/property_tree/ptree.hpp>
+
+#include "tgbot/net/HttpReqArg.h"
+#include "tgbot/types/User.h"
+#include "tgbot/types/Message.h"
+#include "tgbot/types/GenericReply.h"
+#include "tgbot/types/InputFile.h"
+#include "tgbot/types/UserProfilePhotos.h"
+#include "tgbot/types/Update.h"
+
+namespace TgBot {
+
+class Bot;
+
+/**
+ * This class executes telegram api methods. Telegram docs: <https://core.telegram.org/bots/api#available-methods>
+ * @ingroup general
+ */
+class Api {
+
+friend Bot;
+
+public:
+ Api(const std::string& token);
+
+ /**
+ * A simple method for testing your bot's auth token.
+ * @return Basic information about the bot in form of a User object.
+ */
+ User::Ptr getMe() const;
+
+ /**
+ * Use this method to send text messages.
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param text Text of the message to be sent.
+ * @param disableWebPagePreview Optional. Disables link previews for links in this message.
+ * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
+ * @param replyMarkup 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 sendMessage(int32_t chatId, const std::string& text, bool disableWebPagePreview = false, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const;
+
+ /**
+ * Use this method to forward messages of any kind.
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param fromChatId Unique identifier for the chat where the original message was sent — User or GroupChat id.
+ * @param messageId Unique message identifier.
+ * @return On success, the sent message is returned.
+ */
+ Message::Ptr forwardMessage(int32_t chatId, int32_t fromChatId, int32_t messageId) const;
+
+ /**
+ * Use this method to send photos.
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param photo Photo to send.
+ * @param caption Optional. Photo caption.
+ * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
+ * @param replyMarkup 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 sendPhoto(int32_t chatId, const InputFile::Ptr& photo, const std::string& caption = "", int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const;
+
+ /**
+ * Use this method to send photos.
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param photo Photo to send. Id of the photo that is already on the Telegram servers.
+ * @param caption Optional. Photo caption.
+ * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
+ * @param replyMarkup 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 sendPhoto(int32_t chatId, const std::string& photo, const std::string& caption = "", int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const;
+
+ /**
+ * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Document).
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param audio Audio to send.
+ * @param duration Duration of sent audio in seconds.
+ * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
+ * @param replyMarkup 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 sendAudio(int32_t chatId, const InputFile::Ptr& audio, int32_t duration = 0, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const;
+
+ /**
+ * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Document).
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param audio Id of the audio that is already on the Telegram servers.
+ * @param duration Duration of sent audio in seconds.
+ * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
+ * @param replyMarkup 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 sendAudio(int32_t chatId, const std::string& audio, int32_t duration = 0, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const;
+
+ /**
+ * Use this method to send general files.
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param document Document to send.
+ * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
+ * @param replyMarkup 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 sendDocument(int32_t chatId, const InputFile::Ptr& document, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const;
+
+ /**
+ * Use this method to send general files.
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param document Id of the document that is already on the Telegram servers.
+ * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
+ * @param replyMarkup 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 sendDocument(int32_t chatId, const std::string& document, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const;
+
+ /**
+ * Use this method to send .webp stickers.
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param sticker Sticker to send.
+ * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
+ * @param replyMarkup 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 sendSticker(int32_t chatId, const InputFile::Ptr& sticker, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const;
+
+ /**
+ * Use this method to send .webp stickers.
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param sticker Id of the sticker that is already on the Telegram servers.
+ * @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.
+ * @return On success, the sent message is returned.
+ */
+ Message::Ptr sendSticker(int32_t chatId, const std::string& sticker, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const;
+
+ /**
+ * Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param video Video to send.
+ * @param replyToMessageId Optional. If the message is a reply, ID of the original message.
+ * @param replyMarkup 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 sendVideo(int32_t chatId, const InputFile::Ptr& video, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const;
+
+ /**
+ * Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param video Id of the video that is already on the Telegram servers.
+ * @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.
+ * @return On success, the sent message is returned.
+ */
+ Message::Ptr sendVideo(int32_t chatId, const std::string& video, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const;
+
+ /**
+ * Use this method to send point on the map.
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param latitude Latitude of location.
+ * @param longitude Longitude of location.
+ * @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.
+ * @return On success, the sent message is returned.
+ */
+ Message::Ptr sendLocation(int32_t chatId, float latitude, float longitude, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const;
+
+ /**
+ * Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
+ * Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot.
+ * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
+ * @param chatId Unique identifier for the message recipient — User or GroupChat id.
+ * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for location data.
+ */
+ void sendChatAction(int32_t chatId, const std::string& action) const;
+
+ /**
+ * Use this method to get a list of profile pictures for a user.
+ * @param userId Unique identifier of the target user.
+ * @param offset Optional. Sequential number of the first photo to be returned. By default, all photos are returned.
+ * @param limit Optional. Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100.
+ * @return A UserProfilePhotos object.
+ */
+ UserProfilePhotos::Ptr getUserProfilePhotos(int32_t userId, int32_t offset = 0, int32_t limit = 100) const;
+
+ /**
+ * Use this method to receive incoming updates using long polling.
+ * This method will not work if an outgoing webhook is set up.
+ * In order to avoid getting duplicate updates, recalculate offset after each server response.
+ * @param offset Optional. Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id.
+ * @param limit Optional. Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100.
+ * @param timeout Optional. Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling.
+ * @return An Array of Update objects
+ */
+ std::vector<Update::Ptr> getUpdates(int32_t offset = 0, int32_t limit = 100, int32_t timeout = 0) const;
+
+ /**
+ * Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts.
+ * If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. www.example.com/<token>. Since nobody else knows your bot‘s token, you can be pretty sure it’s us.
+ * You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up.
+ * We currently do not support self-signed certificates.
+ * Ports currently supported for Webhooks: 443, 80, 88, 8443.
+ * @param url Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration.
+ */
+ void setWebhook(const std::string& url = "") const;
+
+private:
+ boost::property_tree::ptree sendRequest(const std::string& method, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const;
+
+ const std::string _token;
+};
+
+}
+
+#endif //TGBOT_CPP_API_H
diff --git a/include/tgbot/Bot.h b/include/tgbot/Bot.h
new file mode 100644
index 0000000..5e96642
--- /dev/null
+++ b/include/tgbot/Bot.h
@@ -0,0 +1,81 @@
+/*
+ * 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_BOT_H
+#define TGBOT_CPP_BOT_H
+
+#include <string>
+
+#include "tgbot/Api.h"
+#include "tgbot/EventBroadcaster.h"
+#include "tgbot/EventHandler.h"
+
+namespace TgBot {
+
+/**
+ * This object holds other objects specific for this bot instance.
+ * @ingroup general
+ */
+class Bot {
+
+public:
+ explicit Bot(const std::string& token) : _token(token), _api(token), _eventHandler(&_eventBroadcaster) {
+ }
+
+ /**
+ * @return Token for accessing api.
+ */
+ inline const std::string& getToken() const {
+ return _token;
+ }
+
+ /**
+ * @return Object which can execute Telegram Bot API methods.
+ */
+ inline const Api& getApi() const {
+ return _api;
+ }
+
+ /**
+ * @return Object which holds all event listeners.
+ */
+ inline EventBroadcaster& getEvents() {
+ return _eventBroadcaster;
+ }
+
+ /**
+ * @return Object which handles new update objects. Usually it's only needed for TgLongPoll, TgWebhookLocalServer and TgWebhookTcpServer objects.
+ */
+ inline const EventHandler& getEventHandler() const {
+ return _eventHandler;
+ }
+
+private:
+ const std::string _token;
+ const Api _api;
+ EventBroadcaster _eventBroadcaster;
+ const EventHandler _eventHandler;
+};
+
+}
+
+#endif //TGBOT_CPP_BOT_H
diff --git a/include/tgbot/EventBroadcaster.h b/include/tgbot/EventBroadcaster.h
new file mode 100644
index 0000000..03d7df1
--- /dev/null
+++ b/include/tgbot/EventBroadcaster.h
@@ -0,0 +1,117 @@
+/*
+ * 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_EVENTBROADCASTER_H
+#define TGBOT_EVENTBROADCASTER_H
+
+#include <string>
+#include <functional>
+#include <vector>
+#include <map>
+
+#include "tgbot/types/Message.h"
+
+namespace TgBot {
+
+class EventHandler;
+
+/**
+ * This class holds all event listeners.
+ * @ingroup general
+ */
+class EventBroadcaster {
+
+friend EventHandler;
+
+public:
+ typedef std::function<void (const Message::Ptr&)> MessageListener;
+
+ /**
+ * Registers listener which receives all messages which the bot can ever receive.
+ * @param listener Listener.
+ */
+ inline void onAnyMessage(const MessageListener& listener) {
+ _onAnyMessageListeners.push_back(listener);
+ }
+
+ /**
+ * Registers listener which receives all messages with commands (messages with leading '/' char).
+ * @param commandName Command name which listener can handle.
+ * @param listener Listener.
+ */
+ inline void onCommand(const std::string& commandName, const MessageListener& listener) {
+ _onCommandListeners[commandName] = listener;
+ }
+
+ /**
+ * Registers listener which receives all messages with commands (messages with leading '/' char) which haven't been handled by other listeners.
+ * @param listener Listener.
+ */
+ inline void onUnknownCommand(const MessageListener& listener) {
+ _onUnknownCommandListeners.push_back(listener);
+ }
+
+ /**
+ * Registers listener which receives all messages without commands (messages with no leading '/' char)
+ * @param listener Listener.
+ */
+ inline void onNonCommandMessage(const MessageListener& listener) {
+ _onNonCommandMessageListeners.push_back(listener);
+ }
+
+private:
+ inline void broadcastAnyMessage(const Message::Ptr& message) const {
+ for (const MessageListener& item : _onAnyMessageListeners) {
+ item(message);
+ }
+ }
+
+ inline bool broadcastCommand(const std::string command, const Message::Ptr& message) const {
+ std::map<std::string, MessageListener>::const_iterator iter = _onCommandListeners.find(command);
+ if (iter == _onCommandListeners.end()) {
+ return false;
+ }
+ iter->second(message);
+ return true;
+ }
+
+ inline void broadcastUnknownCommand(const Message::Ptr& message) const {
+ for (const MessageListener& item : _onUnknownCommandListeners) {
+ item(message);
+ }
+ }
+
+ inline void broadcastNonCommandMessage(const Message::Ptr& message) const {
+ for (const MessageListener& item : _onNonCommandMessageListeners) {
+ item(message);
+ }
+ }
+
+ std::vector<MessageListener> _onAnyMessageListeners;
+ std::map<std::string, MessageListener> _onCommandListeners;
+ std::vector<MessageListener> _onUnknownCommandListeners;
+ std::vector<MessageListener> _onNonCommandMessageListeners;
+};
+
+}
+
+#endif //TGBOT_EVENTBROADCASTER_H
diff --git a/include/tgbot/EventHandler.h b/include/tgbot/EventHandler.h
new file mode 100644
index 0000000..abcf925
--- /dev/null
+++ b/include/tgbot/EventHandler.h
@@ -0,0 +1,56 @@
+/*
+ * 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_EVENTHANDLER_H
+#define TGBOT_EVENTHANDLER_H
+
+#include "tgbot/EventBroadcaster.h"
+#include "tgbot/types/Update.h"
+#include "tgbot/tools/StringTools.h"
+
+namespace TgBot {
+
+class EventHandler {
+
+public:
+ explicit EventHandler(const EventBroadcaster* broadcaster) : _broadcaster(broadcaster) {
+ }
+
+ inline void handleUpdate(const Update::Ptr& update) const {
+ _broadcaster->broadcastAnyMessage(update->message);
+ if (StringTools::startsWith(update->message->text, "/")) {
+ std::string command = update->message->text.substr(1, update->message->text.find(' ') - 2);
+ if (!_broadcaster->broadcastCommand(command, update->message)) {
+ _broadcaster->broadcastUnknownCommand(update->message);
+ }
+ } else {
+ _broadcaster->broadcastNonCommandMessage(update->message);
+ }
+ }
+
+private:
+ const EventBroadcaster* _broadcaster;
+};
+
+}
+
+#endif //TGBOT_EVENTHANDLER_H
diff --git a/include/tgbot/TgException.h b/include/tgbot/TgException.h
new file mode 100644
index 0000000..6f01fd3
--- /dev/null
+++ b/include/tgbot/TgException.h
@@ -0,0 +1,43 @@
+/*
+ * 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_TGEXCEPTION_H
+#define TGBOT_TGEXCEPTION_H
+
+#include <string>
+#include <stdexcept>
+
+namespace TgBot {
+
+/**
+ * Exception type which is only thrown when Telegram refuses API request.
+ * @ingroup general
+ */
+class TgException : public std::runtime_error {
+
+public:
+ explicit TgException(const std::string description);
+};
+
+}
+
+#endif //TGBOT_TGEXCEPTION_H
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
new file mode 100644
index 0000000..0571c25
--- /dev/null
+++ b/include/tgbot/TgTypeParser.h
@@ -0,0 +1,180 @@
+/*
+ * 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_TGTYPEPARSER_H
+#define TGBOT_CPP_TGTYPEPARSER_H
+
+#include <string>
+
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/json_parser.hpp>
+
+#include "tgbot/types/User.h"
+#include "tgbot/types/GroupChat.h"
+#include "tgbot/types/Message.h"
+#include "tgbot/types/PhotoSize.h"
+#include "tgbot/types/Audio.h"
+#include "tgbot/types/Document.h"
+#include "tgbot/types/Sticker.h"
+#include "tgbot/types/Video.h"
+#include "tgbot/types/Contact.h"
+#include "tgbot/types/Location.h"
+#include "tgbot/types/Update.h"
+#include "tgbot/types/UserProfilePhotos.h"
+#include "tgbot/types/ReplyKeyboardMarkup.h"
+#include "tgbot/types/ReplyKeyboardHide.h"
+#include "tgbot/types/ForceReply.h"
+#include "tgbot/types/GenericReply.h"
+
+namespace TgBot {
+
+class TgTypeParser {
+
+public:
+ static TgTypeParser& getInstance();
+
+ User::Ptr parseUser(const boost::property_tree::ptree& data) const;
+ std::string parseUser(const User::Ptr& object) const;
+ GroupChat::Ptr parseGroupChat(const boost::property_tree::ptree& data) const;
+ std::string parseGroupChat(const GroupChat::Ptr& object) const;
+ Message::Ptr parseMessage(const boost::property_tree::ptree& data) const;
+ std::string parseMessage(const Message::Ptr& object) const;
+ PhotoSize::Ptr parsePhotoSize(const boost::property_tree::ptree& data) const;
+ std::string parsePhotoSize(const PhotoSize::Ptr& object) const;
+ Audio::Ptr parseAudio(const boost::property_tree::ptree& data) const;
+ std::string parseAudio(const Audio::Ptr& object) const;
+ Document::Ptr parseDocument(const boost::property_tree::ptree& data) const;
+ std::string parseDocument(const Document::Ptr& object) const;
+ Sticker::Ptr parseSticker(const boost::property_tree::ptree& data) const;
+ std::string parseSticker(const Sticker::Ptr& object) const;
+ Video::Ptr parseVideo(const boost::property_tree::ptree& data) const;
+ std::string parseVideo(const Video::Ptr& object) const;
+ Contact::Ptr parseContact(const boost::property_tree::ptree& data) const;
+ std::string parseContact(const Contact::Ptr& object) const;
+ Location::Ptr parseLocation(const boost::property_tree::ptree& data) const;
+ std::string parseLocation(const Location::Ptr& object) const;
+ Update::Ptr parseUpdate(const boost::property_tree::ptree& data) const;
+ std::string parseUpdate(const Update::Ptr& object) const;
+ UserProfilePhotos::Ptr parseUserProfilePhotos(const boost::property_tree::ptree& data) const;
+ std::string parseUserProfilePhotos(const UserProfilePhotos::Ptr& object) const;
+ ReplyKeyboardMarkup::Ptr parseReplyKeyboardMarkup(const boost::property_tree::ptree& data) const;
+ std::string parseReplyKeyboardMarkup(const ReplyKeyboardMarkup::Ptr& object) const;
+ ReplyKeyboardHide::Ptr parseReplyKeyboardHide(const boost::property_tree::ptree& data) const;
+ std::string parseReplyKeyboardHide(const ReplyKeyboardHide::Ptr& object) const;
+ ForceReply::Ptr parseForceReply(const boost::property_tree::ptree& data) const;
+ std::string parseForceReply(const ForceReply::Ptr& object) const;
+ GenericChat::Ptr parseGenericChat(const boost::property_tree::ptree& data) const;
+ std::string parseGenericChat(const GenericChat::Ptr& object) const;
+ GenericReply::Ptr parseGenericReply(const boost::property_tree::ptree& data) const;
+ std::string parseGenericReply(const GenericReply::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;
+ }
+
+ template<typename T>
+ std::shared_ptr<T> tryParse(std::shared_ptr<T> (TgTypeParser::*const parseFunc)(const boost::property_tree::ptree&) const, 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<T>();
+ }
+ return (this->*parseFunc)(treeItem->second);
+ }
+
+ template<typename T>
+ std::vector<std::shared_ptr<T>> parseArray(std::shared_ptr<T> (TgTypeParser::*const parseFunc)(const boost::property_tree::ptree&) const, const boost::property_tree::ptree& data, const std::string& keyName) const {
+ std::vector<std::shared_ptr<T>> result;
+ auto treeItem = data.find(keyName);
+ if (treeItem == data.not_found()) {
+ return result;
+ }
+ for (const std::pair<const std::string, boost::property_tree::ptree>& innerTreeItem : treeItem->second) {
+ result.push_back((this->*parseFunc)(innerTreeItem.second));
+ }
+ return result;
+ }
+
+ template<typename T>
+ std::vector<std::vector<std::shared_ptr<T>>> parse2DArray(std::shared_ptr<T> (TgTypeParser::*const parseFunc)(const boost::property_tree::ptree&) const, const boost::property_tree::ptree& data, const std::string& keyName) const {
+ std::vector<std::vector<std::shared_ptr<T>>> result;
+ auto treeItem = data.find(keyName);
+ if (treeItem == data.not_found()) {
+ return result;
+ }
+ for (const std::pair<const std::string, boost::property_tree::ptree>& innerTreeItem : treeItem->second) {
+ std::vector<std::shared_ptr<T>> innerResult;
+ for (const std::pair<const std::string, boost::property_tree::ptree>& innerInnerTreeItem : innerTreeItem.second) {
+ innerResult.push_back((this->*parseFunc)(innerInnerTreeItem.second));
+ }
+ result.push_back(innerResult);
+ }
+ return result;
+ }
+
+ template<typename T>
+ std::string parseArray(std::string (TgTypeParser::*const parseFunc)(const std::shared_ptr<T>&) const, const std::vector<std::shared_ptr<T>>& objects) const {
+ std::string result;
+ result += '[';
+ for (const std::shared_ptr<T>& item : objects) {
+ result += (this->*parseFunc)(item);
+ result += ',';
+ }
+ result.erase(result.length() - 1);
+ result += ']';
+ return result;
+ }
+
+ template<typename T>
+ std::string parse2DArray(std::string (TgTypeParser::*const parseFunc)(const std::shared_ptr<T>&) const, const std::vector<std::vector<std::shared_ptr<T>>>& objects) const {
+ std::string result;
+ result += '[';
+ for (const std::vector<std::shared_ptr<T>>& item : objects) {
+ result += parseArray(parseFunc, item);
+ result += ',';
+ }
+ result.erase(result.length() - 1);
+ result += ']';
+ return result;
+ }
+
+private:
+ template<typename T>
+ void appendToJson(std::string& json, const std::string& varName, const T& value) const {
+ if (value == 0) {
+ return;
+ }
+ json += '"';
+ json += varName;
+ json += "\":";
+ json += value;
+ json += ',';
+ }
+
+ void appendToJson(std::string& json, const std::string& varName, const std::string& value) const;
+};
+
+}
+
+#endif //TGBOT_CPP_TGTYPEPARSER_H
diff --git a/include/tgbot/doxygenMain.h b/include/tgbot/doxygenMain.h
new file mode 100644
index 0000000..9478b4f
--- /dev/null
+++ b/include/tgbot/doxygenMain.h
@@ -0,0 +1,89 @@
+/*
+ * 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_DOXYGENMAIN_H
+#define TGBOT_DOXYGENMAIN_H
+
+/**
+ * @defgroup general
+ * @defgroup types
+ * @defgroup net
+ * @defgroup tools
+ *
+ * @mainpage
+ *
+ * @section Compilation
+ *
+ * Firstly you need to install some dependencies. You have to have boost library at the runtime and cmake at the compilation step to be able to use this library.
+ * On Debian-based distibutives you can do it with these commands:
+ * @code{.sh}
+sudo apt-get install cmake libboost-dev
+ * @endcode
+ *
+ * To compile the library execute this commands:
+ * @code{.sh}
+cd /path/where/you/have/cloned/the/library/repository
+cmake .
+make -j4
+ * @endcode
+ *
+ * That's all. All you have to do now is just link compiled library to your project.
+ *
+ * @section Samples
+ * Simple echo bot which sends everything it recieves:
+ * @code{.cpp}
+int main() {
+ TgBot::Bot bot("PLACE YOUR TOKEN HERE");
+ bot.getEvents().onCommand("start", [&bot](Message::Ptr message) {
+ bot.getApi().sendMessage(message->chat->id, "Hi!");
+ });
+ bot.getEvents().onAnyMessage([&bot](Message::Ptr message) {
+ printf("User wrote %s\n", message->text.c_str());
+ if (StringTools::startsWith(message->text, "/start")) {
+ return;
+ }
+ bot.getApi().sendMessage(message->chat->id, "Your message is: " + message->text);
+ });
+
+ try {
+ printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str());
+
+ TgBot::TgLongPoll longPoll(bot);
+ while (true) {
+ printf("Long poll started\n");
+ longPoll.start();
+ }
+ } catch (TgBot::TgException& e) {
+ printf("error: %s\n", e.what());
+ }
+
+ return 0;
+}
+ * @endcode
+ *
+ * All samples are located [here](https://github.com/reo7sp/tgbot-cpp/tree/master/samples)
+ *
+ * @section Feedback
+ * Feel free to [https://github.com/reo7sp/tgbot-cpp/issues](create new issues on GitHub) or [https://telegram.me/Reo_SP](contact me on Telegram)
+ */
+
+#endif //TGBOT_DOXYGENMAIN_H
diff --git a/include/tgbot/net/HttpClient.h b/include/tgbot/net/HttpClient.h
new file mode 100644
index 0000000..d39e108
--- /dev/null
+++ b/include/tgbot/net/HttpClient.h
@@ -0,0 +1,61 @@
+/*
+ * 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_HTTPCLIENT_H
+#define TGBOT_HTTPCLIENT_H
+
+#include <string>
+
+#include <boost/asio.hpp>
+
+#include "tgbot/net/Url.h"
+#include "tgbot/net/HttpReqArg.h"
+#include "tgbot/net/HttpParser.h"
+
+namespace TgBot {
+
+/**
+ * This class makes http requests.
+ * @ingroup net
+ */
+class HttpClient {
+
+public:
+ /**
+ * Returns instance which lives during all application lifetime.
+ */
+ static HttpClient& getInstance();
+
+ /**
+ * Sends a request to the url.
+ * If there's no args specified, a GET request will be sent, otherwise a POST request will be sent.
+ * If at least 1 arg is marked as file, the content type of a request will be multipart/form-data, otherwise it will be application/x-www-form-urlencoded.
+ */
+ std::string makeRequest(const Url& url, const std::vector<HttpReqArg>& args);
+
+private:
+ boost::asio::io_service _ioService;
+};
+
+}
+
+#endif //TGBOT_HTTPCLIENT_H
diff --git a/include/tgbot/net/HttpParser.h b/include/tgbot/net/HttpParser.h
new file mode 100644
index 0000000..dcb857b
--- /dev/null
+++ b/include/tgbot/net/HttpParser.h
@@ -0,0 +1,68 @@
+/*
+ * 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_HTTPPARSER_H
+#define TGBOT_HTTPPARSER_H
+
+#include <string>
+#include <map>
+
+#include "tgbot/net/Url.h"
+#include "tgbot/net/HttpReqArg.h"
+
+namespace TgBot {
+
+class HttpParser {
+
+public:
+ static HttpParser& getInstance();
+
+ std::string generateRequest(const Url& url, const std::vector<HttpReqArg>& args, bool isKeepAlive = false);
+ std::string generateMultipartFormData(const std::vector<HttpReqArg>& args, const std::string& bondary);
+ std::string generateMultipartBoundary(const std::vector<HttpReqArg>& args);
+ std::string generateWwwFormUrlencoded(const std::vector<HttpReqArg>& args);
+ std::string generateResponse(const std::string& data, const std::string& mimeType = "text/plain", short unsigned statusCode = 200, const std::string& statusStr = "OK", bool isKeepAlive = false);
+
+ inline std::string parseRequest(const std::string& data, std::map<std::string, std::string>& headers) {
+ return parseHttp(true, data, headers);
+ }
+
+ inline std::string parseRequest(const std::string& data) {
+ return parseHttp(true, data);
+ }
+
+ inline std::string parseResponse(const std::string& data, std::map<std::string, std::string>& headers) {
+ return parseHttp(false, data, headers);
+ }
+
+ inline std::string parseResponse(const std::string& data) {
+ return parseHttp(false, data);
+ }
+
+private:
+ std::string parseHttp(bool isRequest, const std::string& data, std::map<std::string, std::string>& headers);
+ std::string parseHttp(bool isRequest, const std::string& data);
+};
+
+}
+
+#endif //TGBOT_HTTPPARSER_H
diff --git a/include/tgbot/net/HttpReqArg.h b/include/tgbot/net/HttpReqArg.h
new file mode 100644
index 0000000..d70e8b5
--- /dev/null
+++ b/include/tgbot/net/HttpReqArg.h
@@ -0,0 +1,69 @@
+/*
+ * 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_HTTPPARAMETER_H
+#define TGBOT_HTTPPARAMETER_H
+
+#include <string>
+
+#include <boost/lexical_cast.hpp>
+
+namespace TgBot {
+
+/**
+ * This class represents argument in POST http requests.
+ * @ingroup net
+ */
+class HttpReqArg {
+
+public:
+ template<typename T>
+ HttpReqArg(const std::string& name, const T& value, bool isFile = false, const std::string& mimeType = "text/plain") :
+ name(name), value(boost::lexical_cast<std::string>(value)), isFile(isFile), mimeType(mimeType)
+ {
+ }
+
+ /**
+ * Name of an argument.
+ */
+ std::string name;
+
+ /**
+ * Value of an argument.
+ */
+ std::string value;
+
+ /**
+ * Should be true if an argument value hold some file contents
+ */
+ bool isFile = false;
+
+ /**
+ * Mime type of an argument value. This field makes sense only if isFile is true.
+ */
+ std::string mimeType = "text/plain";
+};
+
+}
+
+
+#endif //TGBOT_HTTPPARAMETER_H
diff --git a/include/tgbot/net/HttpServer.h b/include/tgbot/net/HttpServer.h
new file mode 100644
index 0000000..0a66900
--- /dev/null
+++ b/include/tgbot/net/HttpServer.h
@@ -0,0 +1,103 @@
+/*
+ * 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_HTTPSERVER_H
+#define TGBOT_HTTPSERVER_H
+
+#include <string>
+
+#include <boost/asio.hpp>
+
+#include "tgbot/net/HttpParser.h"
+
+namespace TgBot {
+
+/**
+ * This class handles HTTP requests from the Internet.
+ * @ingroup net
+ */
+template<typename Protocol>
+class HttpServer {
+
+private:
+ class Connection;
+
+public:
+ typedef std::function<std::string (const std::string&, const std::map<std::string, std::string>)> ServerHandler;
+
+ HttpServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>>& acceptor, const ServerHandler& handler) : _acceptor(acceptor), _handler(handler) {
+ }
+
+ /**
+ * Starts receiving new connections.
+ */
+ void start() {
+ std::shared_ptr<boost::asio::basic_stream_socket<Protocol>> socket(new boost::asio::basic_stream_socket<Protocol>(acceptor->get_io_service()));
+ std::shared_ptr<Connection<Protocol>> connection(new Connection<Protocol>(socket, _handler));
+ acceptor->async_accept(*connection->socket, [this, connection]() {
+ connection->start();
+ start();
+ });
+ _ioService.run();
+ }
+
+ /**
+ * Stops receiving new connections.
+ */
+ void stop() {
+ _ioService.stop();
+ }
+
+private:
+ template<typename Protocol>
+ class Connection {
+
+ public:
+ Connection(std::shared_ptr<boost::asio::basic_stream_socket<Protocol>>& socket, const ServerHandler& handler) : socket(socket), _handler(handler) {
+ boost::asio::socket_base::keep_alive option(true);
+ socket.set_option(option);
+ }
+
+ void start() {
+ data.reserve(10240);
+ socket->async_receive(data, [this]() {
+ std::map<std::string, std::string> headers;
+ std::string body = HttpParser::parseResponse(data, headers);
+ socket->async_send(_handler(body, headers));
+ });
+ }
+
+ std::shared_ptr<boost::asio::basic_stream_socket<Protocol>> socket;
+ std::string data;
+
+ private:
+ const ServerHandler _handler;
+ };
+
+ boost::asio::io_service _ioService;
+ std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>> _acceptor;
+ const ServerHandler _handler;
+};
+
+}
+
+#endif //TGBOT_HTTPSERVER_H
diff --git a/include/tgbot/net/TgLongPoll.h b/include/tgbot/net/TgLongPoll.h
new file mode 100644
index 0000000..932fc6d
--- /dev/null
+++ b/include/tgbot/net/TgLongPoll.h
@@ -0,0 +1,55 @@
+/*
+ * 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_TGLONGPOLL_H
+#define TGBOT_TGLONGPOLL_H
+
+#include "tgbot/Bot.h"
+#include "tgbot/Api.h"
+#include "tgbot/EventHandler.h"
+
+namespace TgBot {
+
+/**
+ * This class handles long polling and updates parsing.
+ * @ingroup net
+ */
+class TgLongPoll {
+
+public:
+ TgLongPoll(const Api* api, const EventHandler* eventHandler);
+ TgLongPoll(const Bot& bot);
+
+ /**
+ * Starts long poll. After new update will come, this method will parse it and send to EventHandler which invokes your listeners. Designed to be executed in a loop.
+ */
+ void start();
+
+private:
+ int32_t _lastUpdateId = 0;
+ const Api* _api;
+ const EventHandler* _eventHandler;
+};
+
+}
+
+#endif //TGBOT_TGLONGPOLL_H
diff --git a/include/tgbot/net/TgWebhookLocalServer.h b/include/tgbot/net/TgWebhookLocalServer.h
new file mode 100644
index 0000000..7835f28
--- /dev/null
+++ b/include/tgbot/net/TgWebhookLocalServer.h
@@ -0,0 +1,51 @@
+/*
+ * 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_TGWEBHOOKTCPSERVER_H
+#define TGBOT_TGWEBHOOKTCPSERVER_H
+
+#include "tgbot/net/TgWebhookServer.h"
+
+namespace TgBot {
+
+/**
+ * This class setups HTTP server for receiving Telegram Update objects from unix socket.
+ * @ingroup net
+ */
+class TgWebhookLocalServer : public TgWebhookServer<boost::asio::local::stream_protocol> {
+
+public:
+ TgWebhookLocalServer(std::shared_ptr<boost::asio::basic_socket_acceptor<boost::asio::local::stream_protocol>>& acceptor, const std::string& path, EventHandler* eventHandler) = delete;
+
+ TgWebhookLocalServer(const std::string& path, const EventHandler* eventHandler) :
+ TgWebhookServer(std::shared_ptr<boost::asio::basic_socket_acceptor<boost::asio::local::stream_protocol>>(new boost::asio::local::stream_protocol::acceptor(_ioService, boost::asio::local::stream_protocol::endpoint(path))), path, eventHandler)
+ {
+ }
+
+ TgWebhookLocalServer(const std::string& path, const Bot& bot) : TgWebhookLocalServer(path, &bot.getEventHandler()) {
+
+ }
+};
+
+}
+
+#endif //TGBOT_TGWEBHOOKTCPSERVER_H
diff --git a/include/tgbot/net/TgWebhookServer.h b/include/tgbot/net/TgWebhookServer.h
new file mode 100644
index 0000000..a8155ff
--- /dev/null
+++ b/include/tgbot/net/TgWebhookServer.h
@@ -0,0 +1,57 @@
+/*
+ * 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_TGHTTPSERVER_H
+#define TGBOT_TGHTTPSERVER_H
+
+#include "tgbot/Bot.h"
+#include "tgbot/EventHandler.h"
+#include "tgbot/TgTypeParser.h"
+#include "tgbot/net/HttpServer.h"
+
+namespace TgBot {
+
+template<typename Protocol>
+class TgWebhookServer : public HttpServer<Protocol> {
+
+public:
+ TgWebhookServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>>& acceptor, const ServerHandler& handler) = delete;
+
+ TgWebhookServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>>& acceptor, const std::string& path, const EventHandler* eventHandler) :
+ HttpServer(acceptor, [this, eventHandler, &path](const std::string& data, const std::map<std::string, std::string>& headers) -> std::string {
+ if (headers["method"] == "POST" && headers["path"] == path) {
+ eventHandler->handleUpdate(TgTypeParser::getInstance().parseUpdate(TgTypeParser::getInstance().parseJson(data)));
+ }
+ return HttpParser::generateResponse("");
+ })
+ {
+ }
+
+ TgWebhookServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>>& acceptor, const std::string& path, const Bot& bot) :
+ TgWebhookServer(acceptor, path, &bot.getEventHandler())
+ {
+ }
+};
+
+}
+
+#endif //TGBOT_TGHTTPSERVER_H
diff --git a/include/tgbot/net/TgWebhookTcpServer.h b/include/tgbot/net/TgWebhookTcpServer.h
new file mode 100644
index 0000000..cac2638
--- /dev/null
+++ b/include/tgbot/net/TgWebhookTcpServer.h
@@ -0,0 +1,50 @@
+/*
+ * 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_TGWEBHOOKTCPSERVER_H
+#define TGBOT_TGWEBHOOKTCPSERVER_H
+
+#include "tgbot/net/TgWebhookServer.h"
+
+namespace TgBot {
+
+/**
+ * This class setups HTTP server for receiving Telegram Update objects from tcp connections.
+ * @ingroup net
+ */
+class TgWebhookTcpServer : public TgWebhookServer<boost::asio::ip::tcp> {
+
+public:
+ TgWebhookTcpServer(std::shared_ptr<boost::asio::basic_socket_acceptor<boost::asio::ip::tcp>>& acceptor, const std::string& path, EventHandler* eventHandler) = delete;
+
+ TgWebhookTcpServer(unsigned short port, const std::string& path, const EventHandler* eventHandler) :
+ TgWebhookServer(std::shared_ptr<boost::asio::basic_socket_acceptor<boost::asio::ip::tcp>>(new boost::asio::ip::tcp::acceptor(_ioService, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port))), path, eventHandler)
+ {
+ }
+
+ TgWebhookTcpServer(const std::string& path, const Bot& bot) : TgWebhookTcpServer(path, &bot.getEventHandler()) {
+ }
+};
+
+}
+
+#endif //TGBOT_TGWEBHOOKTCPSERVER_H
diff --git a/include/tgbot/net/Url.h b/include/tgbot/net/Url.h
new file mode 100644
index 0000000..818e934
--- /dev/null
+++ b/include/tgbot/net/Url.h
@@ -0,0 +1,67 @@
+/*
+ * 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_URL_H
+#define TGBOT_CPP_URL_H
+
+#include <string>
+
+namespace TgBot {
+
+/**
+ * This class parses a string with the url
+ * @ingroup net
+ */
+class Url {
+
+public:
+ Url(const std::string& url);
+
+ /**
+ * Protocol part of an url. Example: https://
+ */
+ std::string protocol;
+
+ /**
+ * Host part of an url. Example: www.example.com
+ */
+ std::string host;
+
+ /**
+ * Path part of an url including preceding '/' char. Example: /index.html
+ */
+ std::string path;
+
+ /**
+ * Query part of an url without '?' char. Example: a=1&b=2&c=3
+ */
+ std::string query;
+
+ /**
+ * Fragment part of an url without '#' char. Example: section1
+ */
+ std::string fragment;
+};
+
+}
+
+#endif //TGBOT_CPP_URL_H
diff --git a/include/tgbot/tools/StringTools.h b/include/tgbot/tools/StringTools.h
new file mode 100644
index 0000000..0a01b0d
--- /dev/null
+++ b/include/tgbot/tools/StringTools.h
@@ -0,0 +1,91 @@
+/*
+ * 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_STRINGTOOLS_H
+#define TGBOT_CPP_STRINGTOOLS_H
+
+#include <vector>
+#include <string>
+#include <sstream>
+
+/**
+ * @ingroup tools
+ */
+namespace StringTools {
+
+/**
+ * Checks if first string is starting with second string and vice-versa
+ * @param str1 First string
+ * @param str2 Second string
+ */
+bool startsWith(const std::string& str1, const std::string& str2);
+
+/**
+ * Checks if first string is ending with second string and vice-versa
+ * @param str1 First string
+ * @param str2 Second string
+ */
+bool endsWith(const std::string& str1, const std::string& str2);
+
+/**
+ * Splits string to smaller substrings which have between them a delimiter. Resulting substrings won't have delimiter.
+ * @param str Source string
+ * @param delimiter Delimiter
+ * @param dest Array to which substrings will be saved.
+ */
+void split(const std::string& str, char delimiter, std::vector<std::string>& dest);
+
+/**
+ * Generates pseudo random string. It's recommended to call srand before this method.
+ * @param length Length of resulting string.
+ */
+std::string generateRandomString(size_t length);
+
+/**
+ * Performs url encode.
+ * @param value Source url string
+ * @return Encoded url string
+ */
+std::string urlEncode(const std::string& value);
+
+/**
+ * Performs url decode.
+ * @param value Encoded url string
+ * @return Decoded url string
+ */
+std::string urlDecode(const std::string& value);
+
+/**
+ * Splits string to smaller substrings which have between them a delimiter. Resulting substrings won't have delimiter.
+ * @param str Source string
+ * @param delimiter Delimiter
+ * @return Array of substrings
+ */
+inline std::vector<std::string> split(const std::string& str, char delimiter) {
+ std::vector<std::string> result;
+ split(str, delimiter, result);
+ return result;
+}
+
+}
+
+#endif //TGBOT_CPP_STRINGTOOLS_H
diff --git a/include/tgbot/types/Audio.h b/include/tgbot/types/Audio.h
new file mode 100644
index 0000000..8e255fe
--- /dev/null
+++ b/include/tgbot/types/Audio.h
@@ -0,0 +1,63 @@
+/*
+ * 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_AUDIO_H
+#define TGBOT_CPP_AUDIO_H
+
+#include <string>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * This object represents an audio file (voice note).
+ * @ingroup types
+ */
+class Audio {
+
+public:
+ typedef std::shared_ptr<Audio> Ptr;
+
+ /**
+ * Unique identifier for this file.
+ */
+ std::string fileId;
+
+ /**
+ * Duration of the audio in seconds as defined by sender.
+ */
+ int32_t duration;
+
+ /**
+ * Optional. MIME type of the file as defined by sender.
+ */
+ std::string mimeType;
+
+ /**
+ * Optional. File size.
+ */
+ int32_t fileSize;
+};
+
+}
+
+#endif //TGBOT_CPP_AUDIO_H
diff --git a/include/tgbot/types/Contact.h b/include/tgbot/types/Contact.h
new file mode 100644
index 0000000..dcd90b0
--- /dev/null
+++ b/include/tgbot/types/Contact.h
@@ -0,0 +1,63 @@
+/*
+ * 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_CONTACT_H
+#define TGBOT_CPP_CONTACT_H
+
+#include <string>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * This object represents a phone contact.
+ * @ingroup types
+ */
+class Contact {
+
+public:
+ typedef std::shared_ptr<Contact> Ptr;
+
+ /**
+ * Contact's phone number.
+ */
+ std::string phoneNumber;
+
+ /**
+ * Contact's first name.
+ */
+ std::string firstName;
+
+ /**
+ * Optional. Contact's last name.
+ */
+ std::string lastName;
+
+ /**
+ * Optional. Contact's user identifier in Telegram.
+ */
+ std::string userId;
+};
+
+}
+
+#endif //TGBOT_CPP_CONTACT_H
diff --git a/include/tgbot/types/Document.h b/include/tgbot/types/Document.h
new file mode 100644
index 0000000..1fd0522
--- /dev/null
+++ b/include/tgbot/types/Document.h
@@ -0,0 +1,70 @@
+/*
+ * 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_DOCUMENT_H
+#define TGBOT_CPP_DOCUMENT_H
+
+#include <string>
+#include <memory>
+
+#include "tgbot/types/PhotoSize.h"
+
+namespace TgBot {
+
+/**
+ * This object represents a general file (as opposed to photos and audio files).
+ * @ingroup types
+ */
+class Document {
+
+public:
+ typedef std::shared_ptr<Document> Ptr;
+
+ /**
+ * Unique file identifier.
+ */
+ std::string fileId;
+
+ /**
+ * Optional. Document thumbnail as defined by sender.
+ */
+ PhotoSize::Ptr thumb;
+
+ /**
+ * Optional. Original filename as defined by sender.
+ */
+ std::string fileName;
+
+ /**
+ * Optional. MIME type of the file as defined by sender.
+ */
+ std::string mimeType;
+
+ /**
+ * Optional. File size.
+ */
+ int32_t fileSize;
+};
+
+}
+
+#endif //TGBOT_CPP_DOCUMENT_H
diff --git a/include/tgbot/types/ForceReply.h b/include/tgbot/types/ForceReply.h
new file mode 100644
index 0000000..237967e
--- /dev/null
+++ b/include/tgbot/types/ForceReply.h
@@ -0,0 +1,58 @@
+/*
+ * 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_FORCEREPLY_H
+#define TGBOT_CPP_FORCEREPLY_H
+
+#include <memory>
+
+#include "tgbot/types/GenericReply.h"
+
+namespace TgBot {
+
+/**
+ * Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot‘s message and tapped ’Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.
+ * Example: A poll bot for groups runs in privacy mode (only receives commands, replies to its messages and mentions). There could be two ways to create a new poll:
+ * Explain the user how to send a command with parameters (e.g. /newpoll question answer1 answer2). May be appealing for hardcore users but lacks modern day polish.
+ * Guide the user through a step-by-step process. ‘Please send me your question’, ‘Cool, now let’s add the first answer option‘, ’Great. Keep adding answer options, then send /done when you‘re ready’.
+ * The last option is definitely more attractive. And if you use ForceReply in your bot‘s questions, it will receive the user’s answers even if it only receives replies, commands and mentions — without any extra work for the user.
+ * @ingroup types
+ */
+class ForceReply : public GenericReply {
+
+public:
+ typedef std::shared_ptr<ForceReply> Ptr;
+
+ /**
+ * Shows reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply'
+ */
+ const bool forceReply = true;
+
+ /**
+ * Optional. Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
+ */
+ bool selective;
+};
+
+}
+
+#endif //TGBOT_CPP_FORCEREPLY_H
diff --git a/include/tgbot/types/GenericChat.h b/include/tgbot/types/GenericChat.h
new file mode 100644
index 0000000..b590312
--- /dev/null
+++ b/include/tgbot/types/GenericChat.h
@@ -0,0 +1,49 @@
+/*
+ * 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_GENERICCHAT_H
+#define TGBOT_CPP_GENERICCHAT_H
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * This abstract class is base of everything to which you can send a message.
+ * @ingroup types
+ */
+class GenericChat {
+
+public:
+ typedef std::shared_ptr<GenericChat> Ptr;
+
+ virtual ~GenericChat() { }
+
+ /**
+ * Unique identifier for this user, bot or group chat
+ */
+ int32_t id;
+};
+
+}
+
+#endif //TGBOT_CPP_GENERICCHAT_H
diff --git a/include/tgbot/types/GenericReply.h b/include/tgbot/types/GenericReply.h
new file mode 100644
index 0000000..124c83a
--- /dev/null
+++ b/include/tgbot/types/GenericReply.h
@@ -0,0 +1,44 @@
+/*
+ * 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_GENERICREPLY_H
+#define TGBOT_CPP_GENERICREPLY_H
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * This abstract class is base of all keyboard related events.
+ * @ingroup types
+ */
+class GenericReply {
+
+public:
+ typedef std::shared_ptr<GenericReply> Ptr;
+
+ virtual ~GenericReply() { }
+};
+
+}
+
+#endif //TGBOT_CPP_GENERICREPLY_H
diff --git a/include/tgbot/types/GroupChat.h b/include/tgbot/types/GroupChat.h
new file mode 100644
index 0000000..5704051
--- /dev/null
+++ b/include/tgbot/types/GroupChat.h
@@ -0,0 +1,50 @@
+/*
+ * 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_GROUPCHAT_H
+#define TGBOT_CPP_GROUPCHAT_H
+
+#include <string>
+#include <memory>
+
+#include "tgbot/types/GenericChat.h"
+
+namespace TgBot {
+
+/**
+ * This object represents a group chat.
+ * @ingroup types
+ */
+class GroupChat : public GenericChat {
+
+public:
+ typedef std::shared_ptr<GroupChat> Ptr;
+
+ /**
+ * Group name.
+ */
+ std::string title;
+};
+
+}
+
+#endif //TGBOT_CPP_GROUPCHAT_H
diff --git a/include/tgbot/types/InputFile.h b/include/tgbot/types/InputFile.h
new file mode 100644
index 0000000..900838d
--- /dev/null
+++ b/include/tgbot/types/InputFile.h
@@ -0,0 +1,54 @@
+/*
+ * 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_INPUTFILE_H
+#define TGBOT_CPP_INPUTFILE_H
+
+#include <string>
+#include <memory>
+#include <utility>
+
+namespace TgBot {
+
+/**
+ * This object represents the contents of a file to be uploaded.
+ * @ingroup types
+ */
+class InputFile {
+
+public:
+ typedef std::shared_ptr<InputFile> Ptr;
+
+ /**
+ * Contents of a file.
+ */
+ std::string data;
+
+ /**
+ * Mime type of a file.
+ */
+ std::string mimeType;
+};
+
+}
+
+#endif //TGBOT_CPP_INPUTFILE_H
diff --git a/include/tgbot/types/Location.h b/include/tgbot/types/Location.h
new file mode 100644
index 0000000..b35fdd7
--- /dev/null
+++ b/include/tgbot/types/Location.h
@@ -0,0 +1,52 @@
+/*
+ * 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_LOCATION_H
+#define TGBOT_CPP_LOCATION_H
+
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * This object represents a point on the map.
+ * @ingroup types
+ */
+class Location {
+
+public:
+ typedef std::shared_ptr<Location> Ptr;
+
+ /**
+ * Longitude as defined by sender.
+ */
+ float longitude;
+
+ /**
+ * Latitude as defined by sender.
+ */
+ float latitude;
+};
+
+}
+
+#endif //TGBOT_CPP_LOCATION_H
diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h
new file mode 100644
index 0000000..de07563
--- /dev/null
+++ b/include/tgbot/types/Message.h
@@ -0,0 +1,165 @@
+/*
+ * 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_MESSAGE_H
+#define TGBOT_CPP_MESSAGE_H
+
+#include <string>
+#include <vector>
+#include <memory>
+
+#include "tgbot/types/User.h"
+#include "tgbot/types/GenericChat.h"
+#include "tgbot/types/Message.h"
+#include "tgbot/types/Audio.h"
+#include "tgbot/types/Document.h"
+#include "tgbot/types/Sticker.h"
+#include "tgbot/types/Video.h"
+#include "tgbot/types/Contact.h"
+#include "tgbot/types/Location.h"
+#include "tgbot/types/PhotoSize.h"
+
+namespace TgBot {
+
+/**
+ * This object represents a message.
+ * @ingroup types
+ */
+class Message {
+
+public:
+ typedef std::shared_ptr<Message> Ptr;
+
+ /**
+ * Unique message identifier.
+ */
+ int32_t messageId;
+
+ /**
+ * Sender.
+ */
+ User::Ptr from;
+
+ /**
+ * Date the message was sent in Unix time.
+ */
+ int32_t date;
+
+ /**
+ * Conversation the message belongs to — user in case of a private message, GroupChat in case of a group.
+ */
+ GenericChat::Ptr chat;
+
+ /**
+ * Optional. For forwarded messages, sender of the original message.
+ */
+ User::Ptr forwardFrom;
+
+ /**
+ * Optional. For forwarded messages, date the original message was sent in Unix time.
+ */
+ int32_t forwardDate;
+
+ /**
+ * Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
+ */
+ Message::Ptr replyToMessage;
+
+ /**
+ * Optional. For text messages, the actual UTF-8 text of the message.
+ */
+ std::string text;
+
+ /**
+ * Optional. Message is an audio file, information about the file.
+ */
+ Audio::Ptr audio;
+
+ /**
+ * Optional. Message is a general file, information about the file.
+ */
+ Document::Ptr document;
+
+ /**
+ * Optional. Message is a photo, available sizes of the photo.
+ */
+ std::vector<PhotoSize::Ptr> photo;
+
+ /**
+ * Optional. Message is a sticker, information about the sticker.
+ */
+ Sticker::Ptr sticker;
+
+ /**
+ * Optional. Message is a video, information about the video.
+ */
+ Video::Ptr video;
+
+ /**
+ * Optional. Message is a shared contact, information about the contact.
+ */
+ Contact::Ptr contact;
+
+ /**
+ * Optional. Message is a shared location, information about the location.
+ */
+ Location::Ptr location;
+
+ /**
+ * Optional. A new member was added to the group, information about them (this member may be bot itself).
+ */
+ User::Ptr newChatParticipant;
+
+ /**
+ * Optional. A member was removed from the group, information about them (this member may be bot itself).
+ */
+ User::Ptr leftChatParticipant;
+
+ /**
+ * Optional. A group title was changed to this value.
+ */
+ std::string newChatTitle;
+
+ /**
+ * Optional. A group photo was change to this value.
+ */
+ std::vector<PhotoSize::Ptr> newChatPhoto;
+
+ /**
+ * Optional. Informs that the group photo was deleted.
+ */
+ bool deleteChatPhoto;
+
+ /**
+ * Optional. Informs that the group has been created.
+ */
+ bool groupChatCreated;
+
+ /**
+ * Optional. Text description of the photo or the video.
+ */
+ std::string caption;
+};
+
+}
+
+#endif //TGBOT_CPP_MESSAGE_H
diff --git a/include/tgbot/types/PhotoSize.h b/include/tgbot/types/PhotoSize.h
new file mode 100644
index 0000000..c616423
--- /dev/null
+++ b/include/tgbot/types/PhotoSize.h
@@ -0,0 +1,63 @@
+/*
+ * 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_PHOTOSIZE_H
+#define TGBOT_CPP_PHOTOSIZE_H
+
+#include <string>
+#include <memory>
+
+namespace TgBot {
+
+/**
+ * This object represents one size of a photo or a file / sticker thumbnail.
+ * @ingroup types
+ */
+class PhotoSize {
+
+public:
+ typedef std::shared_ptr<PhotoSize> Ptr;
+
+ /**
+ * Unique identifier for this file.
+ */
+ std::string fileId;
+
+ /**
+ * Photo width.
+ */
+ int32_t width;
+
+ /**
+ * Photo height.
+ */
+ int32_t height;
+
+ /**
+ * Optional. File size.
+ */
+ int32_t fileSize;
+};
+
+}
+
+#endif //TGBOT_CPP_PHOTOSIZE_H
diff --git a/include/tgbot/types/ReplyKeyboardHide.h b/include/tgbot/types/ReplyKeyboardHide.h
new file mode 100644
index 0000000..18aa101
--- /dev/null
+++ b/include/tgbot/types/ReplyKeyboardHide.h
@@ -0,0 +1,55 @@
+/*
+ * 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_REPLYKEYBOARDHIDE_H
+#define TGBOT_CPP_REPLYKEYBOARDHIDE_H
+
+#include <memory>
+
+#include "tgbot/types/GenericReply.h"
+
+namespace TgBot {
+
+/**
+ * Upon receiving a message with this object, Telegram clients will hide the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup).
+ * @ingroup types
+ */
+class ReplyKeyboardHide : public GenericReply {
+
+public:
+ typedef std::shared_ptr<ReplyKeyboardHide> Ptr;
+
+ /**
+ * Requests clients to hide the custom keyboard.
+ */
+ const bool hideKeyboard = true;
+
+ /**
+ * Optional. Use this parameter if you want to hide keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
+ * Example: A user votes in a poll, bot returns confirmation message in reply to the vote and hides keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet.
+ */
+ bool selective;
+};
+
+}
+
+#endif //TGBOT_CPP_REPLYKEYBOARDHIDE_H
diff --git a/include/tgbot/types/ReplyKeyboardMarkup.h b/include/tgbot/types/ReplyKeyboardMarkup.h
new file mode 100644
index 0000000..0f9ce0d
--- /dev/null
+++ b/include/tgbot/types/ReplyKeyboardMarkup.h
@@ -0,0 +1,67 @@
+/*
+ * 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_REPLYKEYBOARDMARKUP_H
+#define TGBOT_CPP_REPLYKEYBOARDMARKUP_H
+
+#include <string>
+#include <vector>
+#include <memory>
+
+#include "tgbot/types/GenericReply.h"
+
+namespace TgBot {
+
+/**
+ * This object represents a custom keyboard with reply options.
+ * @ingroup types
+ */
+class ReplyKeyboardMarkup : public GenericReply {
+
+public:
+ typedef std::shared_ptr<ReplyKeyboardMarkup> Ptr;
+
+ /**
+ * Array of button rows, each represented by an Array of Strings.
+ */
+ std::vector<std::vector<std::string>> keyboard;
+
+ /**
+ * Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard.
+ */
+ bool resizeKeyboard;
+
+ /**
+ * Optional. Requests clients to hide the keyboard as soon as it's been used. Defaults to false.
+ */
+ bool oneTimeKeyboard;
+
+ /**
+ * Optional. Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
+ * Example: A user requests to change the bot‘s language, bot replies to the request with a keyboard to select the new language. Other users in the group don’t see the keyboard.
+ */
+ bool selective;
+};
+
+}
+
+#endif //TGBOT_CPP_REPLYKEYBOARDMARKUP_H
diff --git a/include/tgbot/types/Sticker.h b/include/tgbot/types/Sticker.h
new file mode 100644
index 0000000..c223081
--- /dev/null
+++ b/include/tgbot/types/Sticker.h
@@ -0,0 +1,70 @@
+/*
+ * 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_STICKER_H
+#define TGBOT_CPP_STICKER_H
+
+#include <string>
+#include <memory>
+
+#include "tgbot/types/PhotoSize.h"
+
+namespace TgBot {
+
+/**
+ * This object represents a general file (as opposed to photos and audio files).
+ * @ingroup types
+ */
+class Sticker {
+
+public:
+ typedef std::shared_ptr<Sticker> Ptr;
+
+ /**
+ * Unique file identifier.
+ */
+ std::string fileId;
+
+ /**
+ * Optional. Sticker width.
+ */
+ int32_t width;
+
+ /**
+ * Optional. Sticker height.
+ */
+ int32_t height;
+
+ /**
+ * Optional. Optional. Sticker thumbnail in .webp or .jpg format.
+ */
+ PhotoSize::Ptr thumb;
+
+ /**
+ * Optional. File size.
+ */
+ int32_t fileSize;
+};
+
+}
+
+#endif //TGBOT_CPP_STICKER_H
diff --git a/include/tgbot/types/Update.h b/include/tgbot/types/Update.h
new file mode 100644
index 0000000..a4d41a4
--- /dev/null
+++ b/include/tgbot/types/Update.h
@@ -0,0 +1,54 @@
+/*
+ * 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_UPDATE_H
+#define TGBOT_CPP_UPDATE_H
+
+#include <memory>
+
+#include "tgbot/types/Message.h"
+
+namespace TgBot {
+
+/**
+ * This object represents an incoming update.
+ * @ingroup types
+ */
+class Update {
+
+public:
+ typedef std::shared_ptr<Update> Ptr;
+
+ /**
+ * The update‘s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order.
+ */
+ int32_t updateId;
+
+ /**
+ * Optional. New incoming message of any kind — text, photo, sticker, etc.
+ */
+ Message::Ptr message;
+};
+
+}
+
+#endif //TGBOT_CPP_UPDATE_H
diff --git a/include/tgbot/types/User.h b/include/tgbot/types/User.h
new file mode 100644
index 0000000..048d20a
--- /dev/null
+++ b/include/tgbot/types/User.h
@@ -0,0 +1,60 @@
+/*
+ * 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_USER_H
+#define TGBOT_CPP_USER_H
+
+#include <string>
+#include <memory>
+
+#include "tgbot/types/GenericChat.h"
+
+namespace TgBot {
+
+/**
+ * This object represents a Telegram user or bot.
+ * @ingroup types
+ */
+class User : public GenericChat {
+
+public:
+ typedef std::shared_ptr<User> Ptr;
+
+ /**
+ * User‘s or bot’s first name.
+ */
+ std::string firstName;
+
+ /**
+ * Optional. User‘s or bot’s last name.
+ */
+ std::string lastName;
+
+ /**
+ * Optional. User‘s or bot’s username.
+ */
+ std::string username;
+};
+
+}
+
+#endif //TGBOT_CPP_USER_H
diff --git a/include/tgbot/types/UserProfilePhotos.h b/include/tgbot/types/UserProfilePhotos.h
new file mode 100644
index 0000000..0079d37
--- /dev/null
+++ b/include/tgbot/types/UserProfilePhotos.h
@@ -0,0 +1,55 @@
+/*
+ * 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_USERPROFILEPHOTOS_H
+#define TGBOT_CPP_USERPROFILEPHOTOS_H
+
+#include <vector>
+#include <memory>
+
+#include "tgbot/types/PhotoSize.h"
+
+namespace TgBot {
+
+/**
+ * This object represent a user's profile pictures.
+ * @ingroup types
+ */
+class UserProfilePhotos {
+
+public:
+ typedef std::shared_ptr<UserProfilePhotos> Ptr;
+
+ /**
+ * Total number of profile pictures the target user has.
+ */
+ int32_t totalCount;
+
+ /**
+ * Requested profile pictures (in up to 4 sizes each).
+ */
+ std::vector<std::vector<PhotoSize::Ptr>> photos;
+};
+
+}
+
+#endif //TGBOT_CPP_USERPROFILEPHOTOS_H
diff --git a/include/tgbot/types/Video.h b/include/tgbot/types/Video.h
new file mode 100644
index 0000000..368f3e1
--- /dev/null
+++ b/include/tgbot/types/Video.h
@@ -0,0 +1,80 @@
+/*
+ * 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_VIDEO_H
+#define TGBOT_CPP_VIDEO_H
+
+#include <string>
+#include <memory>
+
+#include "tgbot/types/PhotoSize.h"
+
+namespace TgBot {
+
+/**
+ * This object represents a video file.
+ * @ingroup types
+ */
+class Video {
+
+public:
+ typedef std::shared_ptr<Video> Ptr;
+
+ /**
+ * Unique identifier for this file.
+ */
+ std::string fileId;
+
+ /**
+ * Video width as defined by sender.
+ */
+ int32_t width;
+
+ /**
+ * Video height as defined by sender.
+ */
+ int32_t height;
+
+ /**
+ * Duration of the video in seconds as defined by sender.
+ */
+ int32_t duration;
+
+ /**
+ * Optional. Video thumbnail.
+ */
+ PhotoSize::Ptr thumb;
+
+ /**
+ * Optional. Mime type of a file as defined by sender
+ */
+ std::string mimeType;
+
+ /**
+ * Optional. File size.
+ */
+ int32_t fileSize;
+};
+
+}
+
+#endif //TGBOT_CPP_VIDEO_H