From 19d632eeb8371ebf2c77b96e2469ba054df3497e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hauke=20Z=C3=BChl?= Date: Wed, 7 Jun 2017 19:59:06 +0200 Subject: [PATCH 1/5] Added path of examples to Doxyfile --- Doxyfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doxyfile b/Doxyfile index 5d4b749..e63fad8 100644 --- a/Doxyfile +++ b/Doxyfile @@ -811,7 +811,7 @@ EXCLUDE_SYMBOLS = # that contain example code fragments that are included (see the \include # command). -EXAMPLE_PATH = +EXAMPLE_PATH = examples/ # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and From a2ebbd2323a6fee610b5e30b740da8443df4b2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hauke=20Z=C3=BChl?= Date: Wed, 7 Jun 2017 20:22:45 +0200 Subject: [PATCH 2/5] More docu --- src/TelegramBot.cc | 75 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 7 deletions(-) diff --git a/src/TelegramBot.cc b/src/TelegramBot.cc index 0820e7c..4085834 100644 --- a/src/TelegramBot.cc +++ b/src/TelegramBot.cc @@ -17,7 +17,9 @@ #define API_URL "https://api.telegram.org/bot" /** - *Constructor of Bot + * Constructor of Bot + * + * Calls init */ Telegram::TelegramBot::TelegramBot() { @@ -28,7 +30,10 @@ Telegram::TelegramBot::TelegramBot() { /** * Constructor of bot * - * @param token a std::string + * Sets the API URL and calls init + * + * @param token a std::string storing the bot token + * */ Telegram::TelegramBot::TelegramBot(std::string token) { @@ -84,6 +89,11 @@ void Telegram::TelegramBot::processMessage(std::string message) { } } +/** + * A simple command to the API to get some information about the bot. + * + * @return Telegram::User* a pointer of an object of type Telegram::User + */ Telegram::User *Telegram::TelegramBot::getMe(void) { Json::Value obj; @@ -95,7 +105,12 @@ Telegram::User *Telegram::TelegramBot::getMe(void) { } /** - * Send a text message to a user + * Send a text message to a user or group + * + * @param message The text of the message + * @param chat_id the chat id + * + * @return A pointer to a Telegram message object */ Telegram::Message *Telegram::TelegramBot::sendMessage(std::string message, Json::Int64 chat_id) { @@ -104,6 +119,11 @@ Telegram::Message *Telegram::TelegramBot::sendMessage(std::string message, Json: /** * sendMessage sends a simple text message to a given chat (might be a user or a group) + * + * @param message The text of the message + * @param chat_id the chat id + * + * @return A pointer to a Telegram message object */ Telegram::Message* Telegram::TelegramBot::sendMessage(std::string message, std::string chat_id) { @@ -120,6 +140,11 @@ Telegram::Message* Telegram::TelegramBot::sendMessage(std::string message, std:: /** * Sends a picture from the internet to a chat + * + * @param URL The URL of the picture + * @param chat_id the chat id + * + * @return A pointer to a Telegram message object */ Telegram::Message* Telegram::TelegramBot::sendPhoto(std::string URL, Json::Int64 chat_id) { @@ -128,6 +153,11 @@ Telegram::Message* Telegram::TelegramBot::sendPhoto(std::string URL, Json::Int64 /** * Sends a picture from the internet to a chat + * + * @param URL The URL of the picture + * @param chat_id the chat id + * + * @return A pointer to a Telegram message object */ Telegram::Message* Telegram::TelegramBot::sendPhoto(std::string URL, std::string chat_id) { @@ -154,12 +184,22 @@ Telegram::Message *Telegram::TelegramBot::getMessage() { return(this->msg); } +/** + * getCommandMap return the complete command list of the bot + * + * @return Map of the commands + */ Telegram::TCommandMap Telegram::TelegramBot::getCommandMap() { return(this->command_map); } // Private methods + +/** + * inits the bot. That is only sending a content-type to stdout in case + * one uses the bot by an CGI script + */ void Telegram::TelegramBot::init() { std::cout << "Content-type: text/html\r\n\r\n" << std::endl; @@ -167,6 +207,11 @@ void Telegram::TelegramBot::init() { /** * A generic API request + * + * Might be removed in future! + * + * @param method might be sendPhoto, sendMessage or any command defined by Telegram's API + * @param parameters a map of further parameters, needed by the API call */ void Telegram::TelegramBot::apiRequest(std::string method, std::map parameters) { @@ -204,6 +249,11 @@ void Telegram::TelegramBot::apiRequest(std::string method, std::map parameters) { @@ -246,9 +296,9 @@ Json::Value Telegram::TelegramBot::apiRequestJson(std::string method, std::map Date: Wed, 7 Jun 2017 20:27:41 +0200 Subject: [PATCH 3/5] Hint to example01 added --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 3b98139..eb9eb2f 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,12 @@ To compile and install the lib: To use the library, you need: * libcurlpp * libjsoncpp + +You can use example01.cc to start your own bot or CGI script. + +Do not forget to send your web hook URL to Telegram's API network, +otherwise, you cannot send commands to your bot. + +In case you build a CGI script, do not forget to add a valid +certificate to your web server, because your bot is only called via +HTTPS! From 88d07d78b089ced4c436679bcea5226831c95c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hauke=20Z=C3=BChl?= Date: Wed, 7 Jun 2017 20:29:11 +0200 Subject: [PATCH 4/5] Updated HTML files --- doc/html/Audio_8cc.html | 2 +- doc/html/Audio_8cc_source.html | 2 +- doc/html/Audio_8h.html | 2 +- doc/html/Audio_8h_source.html | 2 +- doc/html/Chat_8cc.html | 2 +- doc/html/Chat_8cc_source.html | 2 +- doc/html/Chat_8h.html | 2 +- doc/html/Chat_8h_source.html | 2 +- doc/html/Contact_8cc.html | 2 +- doc/html/Contact_8cc_source.html | 2 +- doc/html/Contact_8h.html | 2 +- doc/html/Contact_8h_source.html | 2 +- doc/html/Document_8cc.html | 2 +- doc/html/Document_8cc_source.html | 2 +- doc/html/Document_8h.html | 2 +- doc/html/Document_8h_source.html | 2 +- doc/html/Location_8cc.html | 2 +- doc/html/Location_8cc_source.html | 2 +- doc/html/Location_8h.html | 2 +- doc/html/Location_8h_source.html | 2 +- doc/html/MessageEntity_8cc.html | 2 +- doc/html/MessageEntity_8cc_source.html | 2 +- doc/html/MessageEntity_8h.html | 2 +- doc/html/MessageEntity_8h_source.html | 2 +- doc/html/Message_8cc.html | 2 +- doc/html/Message_8cc_source.html | 2 +- doc/html/Message_8h.html | 2 +- doc/html/Message_8h_source.html | 2 +- doc/html/PhotoSize_8cc.html | 2 +- doc/html/PhotoSize_8cc_source.html | 2 +- doc/html/PhotoSize_8h.html | 2 +- doc/html/PhotoSize_8h_source.html | 2 +- doc/html/README_8md.html | 2 +- doc/html/README_8md_source.html | 12 +- doc/html/Sticker_8cc.html | 2 +- doc/html/Sticker_8cc_source.html | 2 +- doc/html/Sticker_8h.html | 2 +- doc/html/Sticker_8h_source.html | 2 +- doc/html/TelegramBot_8cc.html | 2 +- doc/html/TelegramBot_8cc_source.html | 443 ++++++++++-------- doc/html/TelegramBot_8h.html | 2 +- doc/html/TelegramBot_8h_source.html | 40 +- doc/html/User_8cc.html | 2 +- doc/html/User_8cc_source.html | 2 +- doc/html/User_8h.html | 2 +- doc/html/User_8h_source.html | 2 +- doc/html/Venue_8cc.html | 2 +- doc/html/Venue_8cc_source.html | 2 +- doc/html/Venue_8h.html | 2 +- doc/html/Venue_8h_source.html | 2 +- doc/html/Video_8cc.html | 2 +- doc/html/Video_8cc_source.html | 2 +- doc/html/Video_8h.html | 2 +- doc/html/Video_8h_source.html | 2 +- doc/html/Voice_8cc.html | 2 +- doc/html/Voice_8cc_source.html | 2 +- doc/html/Voice_8h.html | 2 +- doc/html/Voice_8h_source.html | 2 +- doc/html/annotated.html | 2 +- doc/html/classTelegram_1_1Audio-members.html | 2 +- doc/html/classTelegram_1_1Audio.html | 2 +- doc/html/classTelegram_1_1Chat-members.html | 2 +- doc/html/classTelegram_1_1Chat.html | 2 +- .../classTelegram_1_1Contact-members.html | 2 +- doc/html/classTelegram_1_1Contact.html | 2 +- .../classTelegram_1_1Document-members.html | 2 +- doc/html/classTelegram_1_1Document.html | 2 +- .../classTelegram_1_1Location-members.html | 2 +- doc/html/classTelegram_1_1Location.html | 2 +- .../classTelegram_1_1Message-members.html | 2 +- doc/html/classTelegram_1_1Message.html | 2 +- ...lassTelegram_1_1MessageEntity-members.html | 2 +- doc/html/classTelegram_1_1MessageEntity.html | 2 +- .../classTelegram_1_1PhotoSize-members.html | 2 +- doc/html/classTelegram_1_1PhotoSize.html | 2 +- .../classTelegram_1_1Sticker-members.html | 2 +- doc/html/classTelegram_1_1Sticker.html | 2 +- .../classTelegram_1_1TelegramBot-members.html | 37 +- doc/html/classTelegram_1_1TelegramBot.html | 167 ++++++- doc/html/classTelegram_1_1TelegramBot.js | 1 + doc/html/classTelegram_1_1User-members.html | 2 +- doc/html/classTelegram_1_1User.html | 2 +- doc/html/classTelegram_1_1Venue-members.html | 2 +- doc/html/classTelegram_1_1Venue.html | 2 +- doc/html/classTelegram_1_1Video-members.html | 2 +- doc/html/classTelegram_1_1Video.html | 2 +- doc/html/classTelegram_1_1Voice-members.html | 2 +- doc/html/classTelegram_1_1Voice.html | 2 +- doc/html/classes.html | 2 +- .../dir_039e4b39e16cfa52f3a26599d20c8f92.html | 2 +- .../dir_68267d1309a1af8e8297ef4c3efbcdba.html | 2 +- .../dir_d28a4824dc47e487b107a5db32ef43c4.html | 2 +- .../dir_d44c64559bbebec7f509842c48db8b23.html | 2 +- doc/html/example01_8cc.html | 2 +- doc/html/example01_8cc_source.html | 12 +- doc/html/files.html | 2 +- doc/html/functions.html | 5 +- doc/html/functions_func.html | 5 +- doc/html/functions_vars.html | 2 +- doc/html/globals.html | 2 +- doc/html/globals_defs.html | 2 +- doc/html/globals_func.html | 2 +- doc/html/globals_type.html | 2 +- doc/html/http__build__query_8cc.html | 2 +- doc/html/http__build__query_8cc_source.html | 2 +- doc/html/http__build__query_8h.html | 2 +- doc/html/http__build__query_8h_source.html | 2 +- doc/html/index.html | 7 +- doc/html/json__encode_8cc.html | 2 +- doc/html/json__encode_8cc_source.html | 2 +- doc/html/json__encode_8h.html | 2 +- doc/html/json__encode_8h_source.html | 2 +- doc/html/namespaceTelegram.html | 2 +- doc/html/namespacemembers.html | 2 +- doc/html/namespacemembers_type.html | 2 +- doc/html/namespaces.html | 2 +- doc/html/navtree.js | 2 +- doc/html/navtreeindex0.js | 38 +- doc/html/navtreeindex1.js | 1 + doc/html/search/all_0.js | 1 + doc/html/search/functions_0.js | 1 + doc/html/std_8cc.html | 2 +- doc/html/std_8cc_source.html | 2 +- doc/html/std_8h.html | 2 +- doc/html/std_8h_source.html | 2 +- .../structTelegram_1_1TCommand-members.html | 2 +- doc/html/structTelegram_1_1TCommand.html | 2 +- 127 files changed, 593 insertions(+), 403 deletions(-) diff --git a/doc/html/Audio_8cc.html b/doc/html/Audio_8cc.html index 3597dbf..11bc4b9 100644 --- a/doc/html/Audio_8cc.html +++ b/doc/html/Audio_8cc.html @@ -114,7 +114,7 @@ $(document).ready(function(){initNavTree('Audio_8cc.html','');});