diff options
Diffstat (limited to 'src')
36 files changed, 10 insertions, 1889 deletions
diff --git a/src/tgbot/Api.cpp b/src/tgbot/Api.cpp index 8da88c8..913401b 100644 --- a/src/tgbot/Api.cpp +++ b/src/tgbot/Api.cpp @@ -94,10 +94,13 @@ Message::Ptr Api::sendPhoto(int32_t chatId, const string& photo, const string& c return TgTypeParser::getInstance().parseMessage(sendRequest("sendPhoto", args).find("result")->second); } -Message::Ptr Api::sendAudio(int32_t chatId, const InputFile::Ptr& audio, int32_t replyToMessageId, const GenericReply::Ptr& replyMarkup) const { +Message::Ptr Api::sendAudio(int32_t chatId, const InputFile::Ptr& audio, int32_t duration = 0, int32_t replyToMessageId, const GenericReply::Ptr& replyMarkup) const { vector<HttpReqArg> args; args.push_back(HttpReqArg("chat_id", chatId)); args.push_back(HttpReqArg("audio", audio->data, true, audio->mimeType)); + if (duration) { + args.push_back(HttpReqArg("duration", duration)); + } if (replyToMessageId) { args.push_back(HttpReqArg("reply_to_message_id", replyToMessageId)); } @@ -107,10 +110,13 @@ Message::Ptr Api::sendAudio(int32_t chatId, const InputFile::Ptr& audio, int32_t return TgTypeParser::getInstance().parseMessage(sendRequest("sendAudio", args).find("result")->second); } -Message::Ptr Api::sendAudio(int32_t chatId, const string& audio, int32_t replyToMessageId, const GenericReply::Ptr& replyMarkup) const { +Message::Ptr Api::sendAudio(int32_t chatId, const string& audio, int32_t duration = 0, int32_t replyToMessageId, const GenericReply::Ptr& replyMarkup) const { vector<HttpReqArg> args; args.push_back(HttpReqArg("chat_id", chatId)); args.push_back(HttpReqArg("audio", audio)); + if (duration) { + args.push_back(HttpReqArg("duration", duration)); + } if (replyToMessageId) { args.push_back(HttpReqArg("reply_to_message_id", replyToMessageId)); } diff --git a/src/tgbot/Api.h b/src/tgbot/Api.h deleted file mode 100644 index 384de55..0000000 --- a/src/tgbot/Api.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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; - -class Api { - -friend Bot; - -public: - Api(const std::string& token); - - User::Ptr getMe() const; - Message::Ptr sendMessage(int32_t chatId, const std::string& text, bool disableWebPagePreview = false, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const; - Message::Ptr forwardMessage(int32_t chatId, int32_t fromChatId, int32_t messageId) const; - 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; - 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; - Message::Ptr sendAudio(int32_t chatId, const InputFile::Ptr& audio, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const; - Message::Ptr sendAudio(int32_t chatId, const std::string& audio, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const; - Message::Ptr sendDocument(int32_t chatId, const InputFile::Ptr& document, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const; - Message::Ptr sendDocument(int32_t chatId, const std::string& document, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const; - Message::Ptr sendSticker(int32_t chatId, const InputFile::Ptr& sticker, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const; - Message::Ptr sendSticker(int32_t chatId, const std::string& sticker, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const; - Message::Ptr sendVideo(int32_t chatId, const InputFile::Ptr& video, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const; - Message::Ptr sendVideo(int32_t chatId, const std::string& video, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const; - Message::Ptr sendLocation(int32_t chatId, float latitude, float longitude, int32_t replyToMessageId = 0, const GenericReply::Ptr& replyMarkup = GenericReply::Ptr()) const; - void sendChatAction(int32_t chatId, const std::string& action) const; - UserProfilePhotos::Ptr getUserProfilePhotos(int32_t userId, int32_t offset = 0, int32_t limit = 100) const; - std::vector<Update::Ptr> getUpdates(int32_t offset = 0, int32_t limit = 100, int32_t timeout = 0) const; - 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/src/tgbot/Bot.h b/src/tgbot/Bot.h deleted file mode 100644 index eeef27a..0000000 --- a/src/tgbot/Bot.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 { - -class Bot { - -public: - explicit Bot(const std::string& token) : _token(token), _api(token), _eventHandler(&_eventBroadcaster) { - } - - inline const std::string& getToken() const { - return _token; - } - - inline const Api& getApi() const { - return _api; - } - - inline EventBroadcaster& getEvents() { - return _eventBroadcaster; - } - - 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/src/tgbot/EventBroadcaster.h b/src/tgbot/EventBroadcaster.h deleted file mode 100644 index a6074e8..0000000 --- a/src/tgbot/EventBroadcaster.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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; - -class EventBroadcaster { - -friend EventHandler; - -public: - typedef std::function<void (const Message::Ptr&)> MessageListener; - - inline void onAnyMessage(const MessageListener& listener) { - _onAnyMessageListeners.push_back(listener); - } - - inline void onCommand(const std::string& commandName, const MessageListener& listener) { - _onCommandListeners[commandName] = listener; - } - - inline void onUnknownCommand(const MessageListener& listener) { - _onUnknownCommandListeners.push_back(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/src/tgbot/EventHandler.h b/src/tgbot/EventHandler.h deleted file mode 100644 index abcf925..0000000 --- a/src/tgbot/EventHandler.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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/src/tgbot/TgException.h b/src/tgbot/TgException.h deleted file mode 100644 index c283a06..0000000 --- a/src/tgbot/TgException.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 { - -class TgException : public std::runtime_error { - -public: - explicit TgException(const std::string description); -}; - -} - -#endif //TGBOT_TGEXCEPTION_H diff --git a/src/tgbot/TgTypeParser.cpp b/src/tgbot/TgTypeParser.cpp index 7abcc0e..70588da 100644 --- a/src/tgbot/TgTypeParser.cpp +++ b/src/tgbot/TgTypeParser.cpp @@ -99,6 +99,7 @@ Message::Ptr TgTypeParser::parseMessage(const ptree& data) const { result->newChatPhoto = parseArray<PhotoSize>(parsePhotoSize, data, "new_chat_photo"); result->deleteChatPhoto = data.get("delete_chat_photo", false); result->groupChatCreated = data.get("group_chat_created", false); + result->caption = data.get("caption", false); return result; } @@ -129,6 +130,7 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const { appendToJson(result, "new_chat_photo", parseArray(parsePhotoSize, object->newChatPhoto)); appendToJson(result, "delete_chat_photo", object->deleteChatPhoto); appendToJson(result, "group_chat_created", object->groupChatCreated); + appendToJson(result, "caption", object->caption); result.erase(result.length() - 1); result += '}'; return result; @@ -243,7 +245,6 @@ Video::Ptr TgTypeParser::parseVideo(const ptree& data) const { result->thumb = parsePhotoSize(data.find("thumb")->second); result->mimeType = data.get("mime_type", ""); result->fileSize = data.get("file_size", 0); - result->caption = data.get("caption", ""); return result; } @@ -260,7 +261,6 @@ string TgTypeParser::parseVideo(const Video::Ptr& object) const { appendToJson(result, "thumb", parsePhotoSize(object->thumb)); appendToJson(result, "mime_type", object->mimeType); appendToJson(result, "file_size", object->fileSize); - appendToJson(result, "caption", object->caption); result.erase(result.length() - 1); result += '}'; return result; diff --git a/src/tgbot/TgTypeParser.h b/src/tgbot/TgTypeParser.h deleted file mode 100644 index 0571c25..0000000 --- a/src/tgbot/TgTypeParser.h +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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/src/tgbot/net/HttpClient.h b/src/tgbot/net/HttpClient.h deleted file mode 100644 index 4b84dc3..0000000 --- a/src/tgbot/net/HttpClient.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 { - -class HttpClient { - -public: - static HttpClient& getInstance(); - - std::string makeRequest(const Url& url, const std::vector<HttpReqArg>& args); - -private: - boost::asio::io_service _ioService; -}; - -} - -#endif //TGBOT_HTTPCLIENT_H diff --git a/src/tgbot/net/HttpParser.h b/src/tgbot/net/HttpParser.h deleted file mode 100644 index dcb857b..0000000 --- a/src/tgbot/net/HttpParser.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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/src/tgbot/net/HttpReqArg.h b/src/tgbot/net/HttpReqArg.h deleted file mode 100644 index e906e94..0000000 --- a/src/tgbot/net/HttpReqArg.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 { - -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) - { - } - - std::string name; - std::string value; - bool isFile = false; - std::string mimeType; -}; - -} - - -#endif //TGBOT_HTTPPARAMETER_H diff --git a/src/tgbot/net/HttpServer.h b/src/tgbot/net/HttpServer.h deleted file mode 100644 index 92a667a..0000000 --- a/src/tgbot/net/HttpServer.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 { - -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) { - } - - 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(); - } - - 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/src/tgbot/net/TgLongPoll.h b/src/tgbot/net/TgLongPoll.h deleted file mode 100644 index 6c5175e..0000000 --- a/src/tgbot/net/TgLongPoll.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 { - -class TgLongPoll { - -public: - TgLongPoll(const Api* api, const EventHandler* eventHandler); - TgLongPoll(const Bot& bot); - - void start(); - -private: - int32_t _lastUpdateId = 0; - const Api* _api; - const EventHandler* _eventHandler; -}; - -} - -#endif //TGBOT_TGLONGPOLL_H diff --git a/src/tgbot/net/TgWebhookLocalServer.h b/src/tgbot/net/TgWebhookLocalServer.h deleted file mode 100644 index ec99ad7..0000000 --- a/src/tgbot/net/TgWebhookLocalServer.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 { - -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/src/tgbot/net/TgWebhookServer.h b/src/tgbot/net/TgWebhookServer.h deleted file mode 100644 index a8155ff..0000000 --- a/src/tgbot/net/TgWebhookServer.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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/src/tgbot/net/TgWebhookTcpServer.h b/src/tgbot/net/TgWebhookTcpServer.h deleted file mode 100644 index 4dc58e1..0000000 --- a/src/tgbot/net/TgWebhookTcpServer.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 { - -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/src/tgbot/net/Url.h b/src/tgbot/net/Url.h deleted file mode 100644 index 39ae348..0000000 --- a/src/tgbot/net/Url.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 { - -class Url { - -public: - Url(const std::string& url); - - std::string protocol; - std::string host; - std::string path; - std::string query; - std::string fragment; -}; - -} - -#endif //TGBOT_CPP_URL_H diff --git a/src/tgbot/tools/StringTools.h b/src/tgbot/tools/StringTools.h deleted file mode 100644 index 37ab858..0000000 --- a/src/tgbot/tools/StringTools.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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> - -namespace StringTools { - -bool startsWith(const std::string& str1, const std::string& str2); -bool endsWith(const std::string& str1, const std::string& str2); -void split(const std::string& str, char delimiter, std::vector<std::string>& dest); -std::string generateRandomString(size_t length); -std::string urlEncode(const std::string& value); -std::string urlDecode(const std::string& value); - -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/src/tgbot/types/Audio.h b/src/tgbot/types/Audio.h deleted file mode 100644 index 56374e4..0000000 --- a/src/tgbot/types/Audio.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 { - -class Audio { - -public: - typedef std::shared_ptr<Audio> Ptr; - - std::string fileId; - int32_t duration; - std::string mimeType; - int32_t fileSize; -}; - -} - -#endif //TGBOT_CPP_AUDIO_H diff --git a/src/tgbot/types/Contact.h b/src/tgbot/types/Contact.h deleted file mode 100644 index 1e79e53..0000000 --- a/src/tgbot/types/Contact.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 { - -class Contact { - -public: - typedef std::shared_ptr<Contact> Ptr; - - std::string phoneNumber; - std::string firstName; - std::string lastName; - std::string userId; -}; - -} - -#endif //TGBOT_CPP_CONTACT_H diff --git a/src/tgbot/types/Document.h b/src/tgbot/types/Document.h deleted file mode 100644 index 6dd32c7..0000000 --- a/src/tgbot/types/Document.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 { - -class Document { - -public: - typedef std::shared_ptr<Document> Ptr; - - std::string fileId; - PhotoSize::Ptr thumb; - std::string fileName; - std::string mimeType; - int32_t fileSize; -}; - -} - -#endif //TGBOT_CPP_DOCUMENT_H diff --git a/src/tgbot/types/ForceReply.h b/src/tgbot/types/ForceReply.h deleted file mode 100644 index d0ee706..0000000 --- a/src/tgbot/types/ForceReply.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 { - -class ForceReply : public GenericReply { - -public: - typedef std::shared_ptr<ForceReply> Ptr; - - const bool forceReply = true; - bool selective; -}; - -} - -#endif //TGBOT_CPP_FORCEREPLY_H diff --git a/src/tgbot/types/GenericChat.h b/src/tgbot/types/GenericChat.h deleted file mode 100644 index f641620..0000000 --- a/src/tgbot/types/GenericChat.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 { - -class GenericChat { - -public: - typedef std::shared_ptr<GenericChat> Ptr; - - virtual ~GenericChat() { } - - int32_t id; -}; - -} - -#endif //TGBOT_CPP_GENERICCHAT_H diff --git a/src/tgbot/types/GenericReply.h b/src/tgbot/types/GenericReply.h deleted file mode 100644 index 5b03ea5..0000000 --- a/src/tgbot/types/GenericReply.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 { - -class GenericReply { - -public: - typedef std::shared_ptr<GenericReply> Ptr; - - virtual ~GenericReply() { } -}; - -} - -#endif //TGBOT_CPP_GENERICREPLY_H diff --git a/src/tgbot/types/GroupChat.h b/src/tgbot/types/GroupChat.h deleted file mode 100644 index e9f1989..0000000 --- a/src/tgbot/types/GroupChat.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 { - -class GroupChat : public GenericChat { - -public: - typedef std::shared_ptr<GroupChat> Ptr; - - std::string title; -}; - -} - -#endif //TGBOT_CPP_GROUPCHAT_H diff --git a/src/tgbot/types/InputFile.h b/src/tgbot/types/InputFile.h deleted file mode 100644 index 0c92d80..0000000 --- a/src/tgbot/types/InputFile.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 { - -class InputFile { - -public: - typedef std::shared_ptr<InputFile> Ptr; - - std::string data; - std::string mimeType; -}; - -} - -#endif //TGBOT_CPP_INPUTFILE_H diff --git a/src/tgbot/types/Location.h b/src/tgbot/types/Location.h deleted file mode 100644 index e689d71..0000000 --- a/src/tgbot/types/Location.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { - -class Location { - -public: - typedef std::shared_ptr<Location> Ptr; - - float longitude; - float latitude; -}; - -} - -#endif //TGBOT_CPP_LOCATION_H diff --git a/src/tgbot/types/Message.h b/src/tgbot/types/Message.h deleted file mode 100644 index 155a66c..0000000 --- a/src/tgbot/types/Message.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 { - -class Message { - -public: - typedef std::shared_ptr<Message> Ptr; - - int32_t messageId; - User::Ptr from; - int32_t date; - GenericChat::Ptr chat; - User::Ptr forwardFrom; - int32_t forwardDate; - Message::Ptr replyToMessage; - std::string text; - Audio::Ptr audio; - Document::Ptr document; - std::vector<PhotoSize::Ptr> photo; - Sticker::Ptr sticker; - Video::Ptr video; - Contact::Ptr contact; - Location::Ptr location; - User::Ptr newChatParticipant; - User::Ptr leftChatParticipant; - std::string newChatTitle; - std::vector<PhotoSize::Ptr> newChatPhoto; - bool deleteChatPhoto; - bool groupChatCreated; -}; - -} - -#endif //TGBOT_CPP_MESSAGE_H diff --git a/src/tgbot/types/PhotoSize.h b/src/tgbot/types/PhotoSize.h deleted file mode 100644 index b048c15..0000000 --- a/src/tgbot/types/PhotoSize.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 { - -class PhotoSize { - -public: - typedef std::shared_ptr<PhotoSize> Ptr; - - std::string fileId; - int32_t width; - int32_t height; - int32_t fileSize; -}; - -} - -#endif //TGBOT_CPP_PHOTOSIZE_H diff --git a/src/tgbot/types/ReplyKeyboardHide.h b/src/tgbot/types/ReplyKeyboardHide.h deleted file mode 100644 index f1dc867..0000000 --- a/src/tgbot/types/ReplyKeyboardHide.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 { - -class ReplyKeyboardHide : public GenericReply { - -public: - typedef std::shared_ptr<ReplyKeyboardHide> Ptr; - - const bool hideKeyboard = true; - bool selective; -}; - -} - -#endif //TGBOT_CPP_REPLYKEYBOARDHIDE_H diff --git a/src/tgbot/types/ReplyKeyboardMarkup.h b/src/tgbot/types/ReplyKeyboardMarkup.h deleted file mode 100644 index 84b7799..0000000 --- a/src/tgbot/types/ReplyKeyboardMarkup.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 { - -class ReplyKeyboardMarkup : public GenericReply { - -public: - typedef std::shared_ptr<ReplyKeyboardMarkup> Ptr; - - std::vector<std::vector<std::string>> keyboard; - bool resizeKeyboard; - bool oneTimeKeyboard; - bool selective; -}; - -} - -#endif //TGBOT_CPP_REPLYKEYBOARDMARKUP_H diff --git a/src/tgbot/types/Sticker.h b/src/tgbot/types/Sticker.h deleted file mode 100644 index 7110ef9..0000000 --- a/src/tgbot/types/Sticker.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 { - -class Sticker { - -public: - typedef std::shared_ptr<Sticker> Ptr; - - std::string fileId; - int32_t width; - int32_t height; - PhotoSize::Ptr thumb; - int32_t fileSize; -}; - -} - -#endif //TGBOT_CPP_STICKER_H diff --git a/src/tgbot/types/Update.h b/src/tgbot/types/Update.h deleted file mode 100644 index a0b7d50..0000000 --- a/src/tgbot/types/Update.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 { - -class Update { - -public: - typedef std::shared_ptr<Update> Ptr; - - int32_t updateId; - Message::Ptr message; -}; - -} - -#endif //TGBOT_CPP_UPDATE_H diff --git a/src/tgbot/types/User.h b/src/tgbot/types/User.h deleted file mode 100644 index 7f0710d..0000000 --- a/src/tgbot/types/User.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 { - -class User : public GenericChat { - -public: - typedef std::shared_ptr<User> Ptr; - - std::string firstName; - std::string lastName; - std::string username; -}; - -} - -#endif //TGBOT_CPP_USER_H diff --git a/src/tgbot/types/UserProfilePhotos.h b/src/tgbot/types/UserProfilePhotos.h deleted file mode 100644 index cef4921..0000000 --- a/src/tgbot/types/UserProfilePhotos.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 { - -class UserProfilePhotos { - -public: - typedef std::shared_ptr<UserProfilePhotos> Ptr; - - int32_t totalCount; - std::vector<std::vector<PhotoSize::Ptr>> photos; -}; - -} - -#endif //TGBOT_CPP_USERPROFILEPHOTOS_H diff --git a/src/tgbot/types/Video.h b/src/tgbot/types/Video.h deleted file mode 100644 index 6c2c441..0000000 --- a/src/tgbot/types/Video.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 { - -class Video { - -public: - typedef std::shared_ptr<Video> Ptr; - - std::string fileId; - int32_t width; - int32_t height; - int32_t duration; - PhotoSize::Ptr thumb; - std::string mimeType; - int32_t fileSize; - std::string caption; -}; - -} - -#endif //TGBOT_CPP_VIDEO_H |