23 #ifndef TGBOT_CPP_API_H 24 #define TGBOT_CPP_API_H 29 #include <boost/property_tree/ptree.hpp> 58 typedef std::shared_ptr<std::vector<std::string>> StringArrayPtr;
63 Api(
const std::string& token);
82 Message::Ptr sendMessage(int64_t chatId,
const std::string& text,
bool disableWebPagePreview =
false, int32_t replyToMessageId = 0,
83 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
107 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
120 Message::Ptr sendPhoto(int64_t chatId,
const std::string& photoId,
const std::string& caption =
"", int32_t replyToMessageId = 0,
121 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
138 const std::string& performer =
"",
const std::string& title =
"", int32_t replyToMessageId = 0,
139 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
155 Message::Ptr sendAudio(int64_t chatId,
const std::string& audioId,
const std::string &caption =
"", int32_t duration = 0,
156 const std::string& performer =
"",
const std::string& title =
"", int32_t replyToMessageId = 0,
157 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
171 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
184 Message::Ptr sendDocument(int64_t chatId,
const std::string& documentId,
const std::string &caption =
"", int32_t replyToMessageId = 0,
185 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
197 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
bool disableNotification =
false)
const;
209 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
bool disableNotification =
false)
const;
237 bool createNewStickerSet(int32_t userId,
const std::string& name,
const std::string& title,
251 bool createNewStickerSet(int32_t userId,
const std::string& name,
const std::string& title,
252 const std::string& pngSticker,
const std::string& emojis,
bool containsMasks =
false,
MaskPosition::Ptr maskPosition =
nullptr)
const;
264 bool addStickerToSet(int32_t userId,
const std::string& name,
const std::string& title,
277 bool addStickerToSet(int32_t userId,
const std::string& name,
const std::string& title,
278 const std::string& pngSticker,
const std::string& emojis,
MaskPosition::Ptr maskPosition =
nullptr)
const;
310 Message::Ptr sendVideo(int64_t chatId,
const InputFile::Ptr video,
bool supportsStreaming =
false, int32_t duration = 0, int32_t width = 0, int32_t height = 0,
const std::string& caption =
"",
311 int32_t replyToMessageId = 0,
const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
328 Message::Ptr sendVideo(int64_t chatId,
const std::string& videoId,
bool supportsStreaming =
false, int32_t duration = 0, int32_t width = 0, int32_t height = 0,
const std::string& caption =
"",
329 int32_t replyToMessageId = 0,
const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
356 Message::Ptr sendVideoNote(int64_t chatId,
const std::string& videoNote, int64_t replyToMessageId = 0,
bool disableNotification =
false,
367 std::vector<Message::Ptr>
sendMediaGroup(int64_t chatId,
const std::vector<InputMedia::Ptr>& media,
368 bool disableNotification =
false, int32_t replyToMessageId = 0)
const;
383 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
397 Message::Ptr sendVoice(int64_t chatId,
const std::string& voiceId,
const std::string& caption =
"",
int duration = 0, int32_t replyToMessageId = 0,
398 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
409 Message::Ptr sendGame(int64_t chatId,
const std::string& gameShortName, int32_t replyToMessageId = 0,
410 const InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>(),
bool disableNotification =
false)
const;
424 int32_t replyToMessageId = 0,
const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
bool disableNotification =
false)
const;
437 int32_t inlineMessageId = 0,
const InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>())
const;
464 Message::Ptr sendVenue(int64_t chatId,
float latitude,
float longitude,
const std::string& title,
const std::string& address,
const std::string& foursquareId =
"",
465 bool disableNotification =
false, int32_t replyToMessageId = 0,
const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>())
const;
478 Message::Ptr sendContact(int64_t chatId,
const std::string& phoneNumber,
const std::string& firstName,
const std::string& lastName =
"",
bool disableNotification =
false,
479 int32_t replyToMessageId = 0,
const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>())
const;
490 void sendChatAction(int64_t chatId,
const std::string& action)
const;
569 bool answerCallbackQuery(
const std::string & callbackQueryId,
const std::string & text=
"",
bool showAlert=
false,
const std::string &url=
"", int32_t cacheTime=0)
const;
582 Message::Ptr editMessageText(
const std::string& text, int64_t chatId=0, int32_t messageId=0,
const std::string& inlineMessageId=
"",
583 const std::string& parseMode =
"",
bool disableWebPagePreview =
false,
const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>())
const;
595 const std::string& inlineMessageId =
"",
const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>())
const;
627 std::vector<Update::Ptr>
getUpdates(int32_t offset = 0, int32_t limit = 100, int32_t timeout = 0,
const StringArrayPtr &allowedUpdates =
nullptr)
const;
639 void setWebhook(
const std::string& url =
"",
const InputFile::Ptr certificate =
nullptr, int32_t maxConnection = 40,
const StringArrayPtr &allowedUpdates =
nullptr)
const;
672 bool answerInlineQuery(
const std::string& inlineQueryId,
const std::vector<InlineQueryResult::Ptr>& results,
673 int32_t cacheTime = 300,
bool isPersonal =
false,
const std::string& nextOffset =
"",
const std::string& switchPmText =
"",
const std::string& switchPmParameter =
"")
const;
682 bool kickChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0)
const;
703 bool restrictChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0,
bool canSendMessages =
false,
704 bool canSendMediaMessages =
false,
bool canSendOtherMessages =
false,
bool canAddWebPagePreviews =
false)
const;
720 bool promoteChatMember(int64_t chatId, int32_t userId,
bool canChangeInfo =
false,
bool canPostMessages =
false,
721 bool canEditMessages =
false,
bool canDeleteMessages =
false,
bool canInviteUsers =
false,
bool canPinMessages =
false,
bool canPromoteMembers =
false)
const;
760 bool setChatTitle(int64_t chatId,
const std::string& title)
const;
777 bool pinChatMessage(int64_t chatId, int32_t messageId,
bool disableNotification =
false)
const;
801 int64_t chatId = 0, int32_t messageId = 0,
const std::string& inlineMessageId =
"")
const;
814 std::vector<GameHighScore::Ptr>
getGameHighScores(int32_t userId, int32_t score,
bool force =
false,
815 bool disableEditMessage =
false, int64_t chatId = 0, int32_t messageId = 0,
const std::string& inlineMessageId =
"")
const;
824 std::string
downloadFile(
const std::string& filePath,
const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>())
const;
827 boost::property_tree::ptree sendRequest(
const std::string& method,
const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>())
const;
829 const std::string _token;
834 #endif //TGBOT_CPP_API_H Chat::Ptr getChat(int64_t chatId) const
Use this method to get up to date information about the chat (current name of the user for one-on-one...
Message::Ptr sendVoice(int64_t chatId, const InputFile::Ptr voice, const std::string &caption="", int duration=0, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >(), const std::string &parseMode="", bool disableNotification=false) const
Use this method to send audio files, if you want Telegram clients to display the file as a playable v...
std::shared_ptr< StickerSet > Ptr
std::shared_ptr< File > Ptr
bool promoteChatMember(int64_t chatId, int32_t userId, bool canChangeInfo=false, bool canPostMessages=false, bool canEditMessages=false, bool canDeleteMessages=false, bool canInviteUsers=false, bool canPinMessages=false, bool canPromoteMembers=false) const
Use this method to promote or demote a user in a supergroup or a channel.
bool unpinChatMessage(int64_t chatId) const
Use this method to unpin a message in a supergroup or a channel.
std::string downloadFile(const std::string &filePath, const std::vector< HttpReqArg > &args=std::vector< HttpReqArg >()) const
Downloads file from Telegram and saves it in memory.
std::vector< Update::Ptr > getUpdates(int32_t offset=0, int32_t limit=100, int32_t timeout=0, const StringArrayPtr &allowedUpdates=nullptr) const
Use this method to receive incoming updates using long polling.
Message::Ptr sendPhoto(int64_t chatId, const InputFile::Ptr photo, const std::string &caption="", int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >(), const std::string &parseMode="", bool disableNotification=false) const
Use this method to send photos.
File::Ptr getFile(const std::string &fileId) const
Use this method to get basic info about a file and prepare it for downloading. For the moment...
bool setChatDescription(int64_t chatId, const std::string &description) const
Use this method to change the description of a supergroup or a channel.
bool setChatTitle(int64_t chatId, const std::string &title) const
Use this method to change the title of a chat.
bool kickChatMember(int64_t chatId, int32_t userId, uint64_t untilDate=0) const
Use this method to kick a user from a group or a supergroup.
bool createNewStickerSet(int32_t userId, const std::string &name, const std::string &title, InputFile::Ptr pngSticker, const std::string &emojis, bool containsMasks=false, MaskPosition::Ptr maskPosition=nullptr) const
Use this method to create new sticker set owned by a user. The bot will be able to edit the created s...
Message::Ptr sendContact(int64_t chatId, const std::string &phoneNumber, const std::string &firstName, const std::string &lastName="", bool disableNotification=false, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >()) const
Use this method to send phone contacts. On success, the sent Message is returned. ...
bool addStickerToSet(int32_t userId, const std::string &name, const std::string &title, InputFile::Ptr pngSticker, const std::string &emojis, MaskPosition::Ptr maskPosition=nullptr) const
Use this method to add a new sticker to a set created by the bot.
bool answerCallbackQuery(const std::string &callbackQueryId, const std::string &text="", bool showAlert=false, const std::string &url="", int32_t cacheTime=0) const
Use this method to send answers to callback queries sent from inline keyboards. The answer will be di...
std::shared_ptr< InlineKeyboardMarkup > Ptr
Message::Ptr sendSticker(int64_t chatId, const InputFile::Ptr sticker, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >(), bool disableNotification=false) const
Use this method to send .webp stickers.
This class executes telegram api methods. Telegram docs: https://core.telegram.org/bots/api#available...
bool setChatStickerSet(int64_t chatId, const std::string &stickerSetName) const
Use this method to get information about a member of a chat. Returns a ChatMember object on success...
std::shared_ptr< Message > Ptr
bool pinChatMessage(int64_t chatId, int32_t messageId, bool disableNotification=false) const
Use this method to pin a message in a supergroup or a channel.
User::Ptr getMe() const
A simple method for testing your bot's auth token.
bool deleteStickerPositionInSet(const std::string &sticker) const
Use this method to delete a sticker from a set created by the bot.
void deleteMessage(int64_t chatId, int32_t messageId) const
Use this method to delete messages sent by bot (or by other users if bot is admin).
bool deleteChatStickerSet(int64_t chatId) const
Use this method to get information about a member of a chat. Returns a ChatMember object on success...
Message::Ptr sendAudio(int64_t chatId, const InputFile::Ptr audio, const std::string &caption="", int32_t duration=0, const std::string &performer="", const std::string &title="", int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >(), const std::string &parseMode="", bool disableNotification=false) const
Use this method to send audio files, if you want Telegram clients to display the file as a playable v...
std::shared_ptr< UserProfilePhotos > Ptr
std::shared_ptr< WebhookInfo > Ptr
WebhookInfo::Ptr getWebhookInfo() const
Use this method to get current webhook status.
Message::Ptr setGameScore(int32_t userId, int32_t score, bool force=false, bool disableEditMessage=false, int64_t chatId=0, int32_t messageId=0, const std::string &inlineMessageId="") const
Use this method to set the score of the specified user in a game.
This object holds other objects specific for this bot instance.
bool unbanChatMember(int64_t chatId, int32_t userId) const
Use this method to unban a previously kicked user in a supergroup.
Message::Ptr sendDocument(int64_t chatId, const InputFile::Ptr document, const std::string &caption="", int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >(), const std::string &parseMode="", bool disableNotification=false) const
Use this method to send general files.
int32_t getChatMembersCount(int64_t chatId) const
Use this method to get the number of members in a chat. Returns Int on success.
std::shared_ptr< GenericReply > Ptr
Message::Ptr editMessageReplyMarkup(int64_t chatId=0, int32_t messageId=0, const std::string &inlineMessageId="", const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >()) const
Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline ...
Message::Ptr forwardMessage(int64_t chatId, int64_t fromChatId, int32_t messageId, bool disableNotification=false) const
Use this method to forward messages of any kind.
Message::Ptr sendLocation(int64_t chatId, float latitude, float longitude, uint32_t livePeriod=0, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >(), bool disableNotification=false) const
Use this method to send point on the map.
std::shared_ptr< Chat > Ptr
Message::Ptr sendVideoNote(int64_t chatId, const InputFile::Ptr videoNote, int64_t replyToMessageId=0, bool disableNotification=false, int32_t duration=0, int32_t length=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr())
Use this method to send video messages. On success, the sent Message is returned. ...
Message::Ptr editMessageLiveLocation(float latitude, float longitude, int64_t chatId=0, int32_t messageId=0, int32_t inlineMessageId=0, const InlineKeyboardMarkup::Ptr replyMarkup=std::make_shared< InlineKeyboardMarkup >()) const
Use this method to edit live location messages sent by the bot or via the bot (for inline bots)...
bool leaveChat(int64_t chatId) const
Use this method for your bot to leave a group, supergroup or channel.
void sendChatAction(int64_t chatId, const std::string &action) const
Use this method when you need to tell the user that something is happening on the bot's side...
File::Ptr uploadStickerFile(int32_t userId, const InputFile::Ptr pngSticker) const
Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStic...
bool answerInlineQuery(const std::string &inlineQueryId, const std::vector< InlineQueryResult::Ptr > &results, int32_t cacheTime=300, bool isPersonal=false, const std::string &nextOffset="", const std::string &switchPmText="", const std::string &switchPmParameter="") const
Use this method to send answers to an inline query. No mode that 50 results per query are allowed...
ChatMember::Ptr getChatMember(int64_t chatId, int32_t userId) const
Use this method to get information about a member of a chat. Returns a ChatMember object on success...
bool setChatPhoto(int64_t chatId, const InputFile::Ptr photo) const
Use this method to set a new profile photo for the chat.
Message::Ptr sendVideo(int64_t chatId, const InputFile::Ptr video, bool supportsStreaming=false, int32_t duration=0, int32_t width=0, int32_t height=0, const std::string &caption="", int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >(), const std::string &parseMode="", bool disableNotification=false) const
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent a...
std::vector< Message::Ptr > sendMediaGroup(int64_t chatId, const std::vector< InputMedia::Ptr > &media, bool disableNotification=false, int32_t replyToMessageId=0) const
Use this method to send a group of photos or videos as an album.
bool deleteWebhook() const
Use this method to remove webhook integration if you decide to switch back to getUpdates.
std::shared_ptr< MaskPosition > Ptr
bool deleteChatPhoto(int64_t chatId) const
Use this method to delete a chat photo.
Message::Ptr sendGame(int64_t chatId, const std::string &gameShortName, int32_t replyToMessageId=0, const InlineKeyboardMarkup::Ptr replyMarkup=std::make_shared< InlineKeyboardMarkup >(), bool disableNotification=false) const
Use this method to send a game.
Api(const std::string &token)
StickerSet::Ptr getStickerSet(const std::string &name) const
Use this method to get a sticker set.
Message::Ptr sendVenue(int64_t chatId, float latitude, float longitude, const std::string &title, const std::string &address, const std::string &foursquareId="", bool disableNotification=false, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >()) const
Use this method to send information about a venue. On success, the sent Message is returned...
Message::Ptr sendMessage(int64_t chatId, const std::string &text, bool disableWebPagePreview=false, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >(), const std::string &parseMode="", bool disableNotification=false) const
Use this method to send text messages.
std::vector< GameHighScore::Ptr > getGameHighScores(int32_t userId, int32_t score, bool force=false, bool disableEditMessage=false, int64_t chatId=0, int32_t messageId=0, const std::string &inlineMessageId="") const
Use this method to get data for high score tables.
std::vector< ChatMember::Ptr > getChatAdministrators(int64_t chatId) const
Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember...
Message::Ptr stopMessageLiveLocation(int64_t chatId=0, int32_t messageId=0, int32_t inlineMessageId=0, const InlineKeyboardMarkup::Ptr replyMarkup=std::make_shared< InlineKeyboardMarkup >()) const
Use this method to edit live location messages sent by the bot or via the bot (for inline bots)...
Message::Ptr editMessageCaption(int64_t chatId=0, int32_t messageId=0, const std::string &caption="", const std::string &inlineMessageId="", const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >()) const
Use this method to edit captions of messages sent by the bot or via the bot (for inline bots)...
bool restrictChatMember(int64_t chatId, int32_t userId, uint64_t untilDate=0, bool canSendMessages=false, bool canSendMediaMessages=false, bool canSendOtherMessages=false, bool canAddWebPagePreviews=false) const
Use this method to restrict a user in a supergroup.
UserProfilePhotos::Ptr getUserProfilePhotos(int32_t userId, int32_t offset=0, int32_t limit=100) const
Use this method to get a list of profile pictures for a user.
std::string exportChatInviteLink(int64_t chatId) const
Use this method to generate a new invite link for a chat; any previously generated link is revoked...
std::shared_ptr< ChatMember > Ptr
void setWebhook(const std::string &url="", const InputFile::Ptr certificate=nullptr, int32_t maxConnection=40, const StringArrayPtr &allowedUpdates=nullptr) const
Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts.
Message::Ptr editMessageText(const std::string &text, int64_t chatId=0, int32_t messageId=0, const std::string &inlineMessageId="", const std::string &parseMode="", bool disableWebPagePreview=false, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >()) const
Use this method to edit text and game messages sent by the bot or via the bot (for inline bots) ...
bool setStickerPositionInSet(const std::string &sticker, uint32_t position) const
Use this method to move a sticker in a set created by the bot to a specific position.
std::shared_ptr< User > Ptr