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