From 12e155f740bc965aea276c43a750fcf4f7d6c1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hauke=20Z=C3=BChl?= Date: Sat, 3 Jun 2017 21:36:51 +0200 Subject: [PATCH] Added sendPhoto --- include/Telegram/TelegramBot.h | 2 ++ src/TelegramBot.cc | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/Telegram/TelegramBot.h b/include/Telegram/TelegramBot.h index 063a837..7be313e 100644 --- a/include/Telegram/TelegramBot.h +++ b/include/Telegram/TelegramBot.h @@ -41,6 +41,8 @@ namespace Telegram { void sendMessage(std::string, Json::Int64); void sendMessage(std::string, std::string); + void sendPhoto(std::string, std::string); + Telegram::Message *getMessage(); std::map getCommandMap(); diff --git a/src/TelegramBot.cc b/src/TelegramBot.cc index eb8a8c7..1b33dd3 100644 --- a/src/TelegramBot.cc +++ b/src/TelegramBot.cc @@ -92,6 +92,9 @@ void Telegram::TelegramBot::sendMessage(std::string message, Json::Int64 chat_id this->sendMessage(message, SSTR(chat_id)); } +/** + * sendMessage sends a simple text message to a given chat (might be a user or a group) + */ void Telegram::TelegramBot::sendMessage(std::string message, std::string chat_id) { std::map params; @@ -101,6 +104,19 @@ void Telegram::TelegramBot::sendMessage(std::string message, std::string chat_id this->apiRequestJson("sendMessage", params); } +/** + * Sends a phot from the internet to a chat + */ +void Telegram::TelegramBot::sendPhoto(std::string URL, std::string chat_id) { + + std::map params; + + params["chat_id"] = chat_id; + params["photo"] = URL; + + this->apiRequestJson("sendPhoto", params); +} + Telegram::Message *Telegram::TelegramBot::getMessage() { return(this->msg);