Browse Source

Added sendPhoto

develop
Hauke Zühl 7 years ago
parent
commit
d6db3e71b7
  1. 2
      include/Telegram/TelegramBot.h
  2. 16
      src/TelegramBot.cc

2
include/Telegram/TelegramBot.h

@ -41,6 +41,8 @@ namespace Telegram {
void sendMessage(std::string, Json::Int64); void sendMessage(std::string, Json::Int64);
void sendMessage(std::string, std::string); void sendMessage(std::string, std::string);
void sendPhoto(std::string, std::string);
Telegram::Message *getMessage(); Telegram::Message *getMessage();
std::map<std::string, TCommand> getCommandMap(); std::map<std::string, TCommand> getCommandMap();

16
src/TelegramBot.cc

@ -92,6 +92,9 @@ void Telegram::TelegramBot::sendMessage(std::string message, Json::Int64 chat_id
this->sendMessage(message, SSTR(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) { void Telegram::TelegramBot::sendMessage(std::string message, std::string chat_id) {
std::map<std::string, std::string> params; std::map<std::string, std::string> params;
@ -101,6 +104,19 @@ void Telegram::TelegramBot::sendMessage(std::string message, std::string chat_id
this->apiRequestJson("sendMessage", params); 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<std::string, std::string> params;
params["chat_id"] = chat_id;
params["photo"] = URL;
this->apiRequestJson("sendPhoto", params);
}
Telegram::Message *Telegram::TelegramBot::getMessage() { Telegram::Message *Telegram::TelegramBot::getMessage() {
return(this->msg); return(this->msg);

Loading…
Cancel
Save