mirror of
https://github.com/UltraCoderRU/telebotxx.git
synced 2026-01-28 04:05:13 +00:00
BotApi::send* now return Message, recieved from server.
This commit is contained in:
parent
2861dc5dff
commit
ff8f9a2e74
2 changed files with 16 additions and 12 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
#define TELEBOTXX_BOTAPI_H
|
#define TELEBOTXX_BOTAPI_H
|
||||||
|
|
||||||
#include "User.hpp"
|
#include "User.hpp"
|
||||||
|
#include "Message.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
@ -31,19 +32,22 @@ namespace telebotxx
|
||||||
/// \param [in] chat chat identifier
|
/// \param [in] chat chat identifier
|
||||||
/// \param [in] text message text
|
/// \param [in] text message text
|
||||||
/// \param [in] parseMode parse mode
|
/// \param [in] parseMode parse mode
|
||||||
void sendMessage(const std::string& chat, const std::string& text, ParseMode parseMode = ParseMode::Plain);
|
/// \return Message object, recieved from the server
|
||||||
|
Message sendMessage(const std::string& chat, const std::string& text, ParseMode parseMode = ParseMode::Plain);
|
||||||
|
|
||||||
/// \brief Send image
|
/// \brief Send image
|
||||||
/// \param [in] chat chat identifier
|
/// \param [in] chat chat identifier
|
||||||
/// \param [in] filename image location
|
/// \param [in] filename image location
|
||||||
/// \param [in] caption optional photo caption
|
/// \param [in] caption optional photo caption
|
||||||
void sendPhoto(const std::string& chat, const std::string& filename, const std::string& caption = "");
|
/// \return Message object, recieved from the server
|
||||||
|
Message sendPhoto(const std::string& chat, const std::string& filename, const std::string& caption = "");
|
||||||
|
|
||||||
/// \brief Send image by URL
|
/// \brief Send image by URL
|
||||||
/// \param [in] chat chat identifier
|
/// \param [in] chat chat identifier
|
||||||
/// \param [in] url image URL
|
/// \param [in] url image URL
|
||||||
/// \param [in] caption optional photo caption
|
/// \param [in] caption optional photo caption
|
||||||
void sendPhotoUrl(const std::string& chat, const std::string& url, const std::string& caption = "");
|
/// \return Message object, recieved from the server
|
||||||
|
Message sendPhotoUrl(const std::string& chat, const std::string& url, const std::string& caption = "");
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public:
|
||||||
return *parseUser(doc, "result", REQUIRED);
|
return *parseUser(doc, "result", REQUIRED);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sendMessage(const std::string& chat, const std::string& text, ParseMode parseMode)
|
inline Message sendMessage(const std::string& chat, const std::string& text, ParseMode parseMode)
|
||||||
{
|
{
|
||||||
// Construct JSON body
|
// Construct JSON body
|
||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
|
|
@ -72,10 +72,10 @@ public:
|
||||||
|
|
||||||
/// \todo Parse message
|
/// \todo Parse message
|
||||||
checkResponse(doc);
|
checkResponse(doc);
|
||||||
MessagePtr message = parseMessage(doc, "result", REQUIRED);
|
return *parseMessage(doc, "result", REQUIRED);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sendPhoto(const std::string& chat, const std::string& filename, const std::string& caption)
|
inline Message sendPhoto(const std::string& chat, const std::string& filename, const std::string& caption)
|
||||||
{
|
{
|
||||||
auto r = cpr::Post(cpr::Url{telegramMainUrl_ + "/sendPhoto"},
|
auto r = cpr::Post(cpr::Url{telegramMainUrl_ + "/sendPhoto"},
|
||||||
cpr::Multipart{{"chat_id", chat},
|
cpr::Multipart{{"chat_id", chat},
|
||||||
|
|
@ -93,10 +93,10 @@ public:
|
||||||
|
|
||||||
/// \todo Parse message
|
/// \todo Parse message
|
||||||
checkResponse(doc);
|
checkResponse(doc);
|
||||||
MessagePtr message = parseMessage(doc, "result", REQUIRED);
|
return *parseMessage(doc, "result", REQUIRED);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sendPhotoUrl(const std::string& chat, const std::string& url, const std::string& caption)
|
inline Message sendPhotoUrl(const std::string& chat, const std::string& url, const std::string& caption)
|
||||||
{
|
{
|
||||||
// Construct JSON body
|
// Construct JSON body
|
||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
|
|
@ -128,7 +128,7 @@ public:
|
||||||
|
|
||||||
/// \todo Parse message
|
/// \todo Parse message
|
||||||
checkResponse(doc);
|
checkResponse(doc);
|
||||||
MessagePtr message = parseMessage(doc, "result", REQUIRED);
|
return *parseMessage(doc, "result", REQUIRED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -150,17 +150,17 @@ User BotApi::getMe()
|
||||||
return impl_->getMe();
|
return impl_->getMe();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BotApi::sendMessage(const std::string& chat, const std::string& text, ParseMode parseMode)
|
Message BotApi::sendMessage(const std::string& chat, const std::string& text, ParseMode parseMode)
|
||||||
{
|
{
|
||||||
return impl_->sendMessage(chat, text, parseMode);
|
return impl_->sendMessage(chat, text, parseMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BotApi::sendPhoto(const std::string& chat, const std::string& filename, const std::string& caption)
|
Message BotApi::sendPhoto(const std::string& chat, const std::string& filename, const std::string& caption)
|
||||||
{
|
{
|
||||||
return impl_->sendPhoto(chat, filename, caption);
|
return impl_->sendPhoto(chat, filename, caption);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BotApi::sendPhotoUrl(const std::string& chat, const std::string& url, const std::string& caption)
|
Message BotApi::sendPhotoUrl(const std::string& chat, const std::string& url, const std::string& caption)
|
||||||
{
|
{
|
||||||
return impl_->sendPhotoUrl(chat, url, caption);
|
return impl_->sendPhotoUrl(chat, url, caption);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue