tgbot-cpp
Api.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Oleg Morozenkov
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all
12  * copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 
23 #ifndef TGBOT_CPP_API_H
24 #define TGBOT_CPP_API_H
25 
26 #include <string>
27 #include <vector>
28 
29 #include <boost/property_tree/ptree.hpp>
30 
31 #include "tgbot/net/HttpReqArg.h"
32 #include "tgbot/types/User.h"
33 #include "tgbot/types/Message.h"
35 #include "tgbot/types/InputFile.h"
37 #include "tgbot/types/Update.h"
39 #include "tgbot/types/Venue.h"
41 #include "tgbot/types/ChatMember.h"
42 #include "tgbot/types/StickerSet.h"
43 #include "tgbot/types/File.h"
44 #include "tgbot/types/InputMedia.h"
48 
49 namespace TgBot {
50 
51 class Bot;
52 
58 class Api {
59 
60 typedef std::shared_ptr<std::vector<std::string>> StringArrayPtr;
61 
62 friend class Bot;
63 
64 public:
65  Api(const std::string& token);
66 
71  User::Ptr getMe() const;
72 
84  Message::Ptr sendMessage(int64_t chatId, const std::string& text, bool disableWebPagePreview = false, int32_t replyToMessageId = 0,
85  const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
86 
95  Message::Ptr forwardMessage(int64_t chatId, int64_t fromChatId, int32_t messageId, bool disableNotification = false) const;
96 
108  Message::Ptr sendPhoto(int64_t chatId, const InputFile::Ptr photo, const std::string& caption = "", int32_t replyToMessageId = 0,
109  const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
110 
122  Message::Ptr sendPhoto(int64_t chatId, const std::string& photoId, const std::string& caption = "", int32_t replyToMessageId = 0,
123  const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
124 
139  Message::Ptr sendAudio(int64_t chatId, const InputFile::Ptr audio, const std::string &caption = "", int32_t duration = 0,
140  const std::string& performer = "", const std::string& title = "", int32_t replyToMessageId = 0,
141  const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
142 
157  Message::Ptr sendAudio(int64_t chatId, const std::string& audioId, const std::string &caption = "", int32_t duration = 0,
158  const std::string& performer = "", const std::string& title = "", int32_t replyToMessageId = 0,
159  const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
160 
172  Message::Ptr sendDocument(int64_t chatId, const InputFile::Ptr document, const std::string &caption = "", int32_t replyToMessageId = 0,
173  const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
174 
186  Message::Ptr sendDocument(int64_t chatId, const std::string& documentId, const std::string &caption = "", int32_t replyToMessageId = 0,
187  const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
188 
216  Message::Ptr sendInvoice(int64_t chatId, const std::string& title, const std::string& description, const std::string& payload,
217  const std::string& providerToken, const std::string& startParameter, const std::string& currency, const std::vector<LabeledPrice::Ptr>& prices,
218  const std::string& providerData = "", const std::string& photoUrl = "", int32_t photoSize = 0,
219  int32_t photoWidth = 0, int32_t photoHeight = 0, bool needName = false,
220  bool needPhoneNumber = false, bool needEmail = false, bool needShippingAddress = false,
221  bool sendPhoneNumberToProvider = false, bool sendEmailToProvider = false, bool isFlexible = false,
222  int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
223 
235  bool answerShippingQuery(const std::string& shippingQueryId, bool ok, const std::vector<ShippingOption::Ptr>& shippingOptions = std::vector<ShippingOption::Ptr>(), const std::string& errorMessage = "") const;
236 
248  bool answerPreCheckoutQuery(const std::string& preCheckoutQueryId, bool ok, const std::string& errorMessage = "") const;
249 
259  Message::Ptr sendSticker(int64_t chatId, const InputFile::Ptr sticker, int32_t replyToMessageId = 0,
260  const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
261 
271  Message::Ptr sendSticker(int64_t chatId, const std::string& stickerId, int32_t replyToMessageId = 0,
272  const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
273 
279  StickerSet::Ptr getStickerSet(const std::string& name) const;
280 
287  File::Ptr uploadStickerFile(int32_t userId, const InputFile::Ptr pngSticker) const;
288 
300  bool createNewStickerSet(int32_t userId, const std::string& name, const std::string& title,
301  InputFile::Ptr pngSticker, const std::string& emojis, bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const;
302 
314  bool createNewStickerSet(int32_t userId, const std::string& name, const std::string& title,
315  const std::string& pngSticker, const std::string& emojis, bool containsMasks = false, MaskPosition::Ptr maskPosition = nullptr) const;
316 
327  bool addStickerToSet(int32_t userId, const std::string& name, const std::string& title,
328  InputFile::Ptr pngSticker, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr) const;
329 
340  bool addStickerToSet(int32_t userId, const std::string& name, const std::string& title,
341  const std::string& pngSticker, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr) const;
342 
349  bool setStickerPositionInSet(const std::string& sticker, uint32_t position) const;
350 
356  bool deleteStickerPositionInSet(const std::string& sticker) const;
357 
373  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 = "",
374  int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
375 
391  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 = "",
392  int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
393 
405  Message::Ptr sendVideoNote(int64_t chatId, const InputFile::Ptr videoNote, int64_t replyToMessageId = 0, bool disableNotification = false,
406  int32_t duration = 0, int32_t length = 0, const GenericReply::Ptr replyMarkup = GenericReply::Ptr());
407 
419  Message::Ptr sendVideoNote(int64_t chatId, const std::string& videoNote, int64_t replyToMessageId = 0, bool disableNotification = false,
420  int32_t duration = 0, int32_t length = 0, const GenericReply::Ptr replyMarkup = GenericReply::Ptr());
421 
430  std::vector<Message::Ptr> sendMediaGroup(int64_t chatId, const std::vector<InputMedia::Ptr>& media,
431  bool disableNotification = false, int32_t replyToMessageId = 0) const;
432 
445  Message::Ptr sendVoice(int64_t chatId, const InputFile::Ptr voice, const std::string& caption = "", int duration = 0, int32_t replyToMessageId = 0,
446  const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
447 
460  Message::Ptr sendVoice(int64_t chatId, const std::string& voiceId, const std::string& caption = "", int duration = 0, int32_t replyToMessageId = 0,
461  const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), const std::string& parseMode = "", bool disableNotification = false) const;
462 
472  Message::Ptr sendGame(int64_t chatId, const std::string& gameShortName, int32_t replyToMessageId = 0,
473  const InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>(), bool disableNotification = false) const;
474 
486  Message::Ptr sendLocation(int64_t chatId, float latitude, float longitude, uint32_t livePeriod = 0,
487  int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(), bool disableNotification = false) const;
488 
499  Message::Ptr editMessageLiveLocation(float latitude, float longitude, int64_t chatId = 0, int32_t messageId = 0,
500  int32_t inlineMessageId = 0, const InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>()) const;
501 
510  Message::Ptr stopMessageLiveLocation(int64_t chatId = 0, int32_t messageId = 0, int32_t inlineMessageId = 0,
511  const InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>()) const;
512 
513 
527  Message::Ptr sendVenue(int64_t chatId, float latitude, float longitude, const std::string& title, const std::string& address, const std::string& foursquareId = "",
528  bool disableNotification = false, int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
529 
541  Message::Ptr sendContact(int64_t chatId, const std::string& phoneNumber, const std::string& firstName, const std::string& lastName = "", bool disableNotification = false,
542  int32_t replyToMessageId = 0, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
543 
553  void sendChatAction(int64_t chatId, const std::string& action) const;
554 
562  UserProfilePhotos::Ptr getUserProfilePhotos(int32_t userId, int32_t offset = 0, int32_t limit = 100) const;
563 
569  File::Ptr getFile(const std::string &fileId) const;
570 
576  bool leaveChat(int64_t chatId) const;
577 
583  Chat::Ptr getChat(int64_t chatId) const;
584 
590  std::vector<ChatMember::Ptr> getChatAdministrators(int64_t chatId) const;
591 
597  int32_t getChatMembersCount(int64_t chatId) const;
598 
605  ChatMember::Ptr getChatMember(int64_t chatId, int32_t userId) const;
606 
613  bool setChatStickerSet(int64_t chatId, const std::string& stickerSetName) const;
614 
620  bool deleteChatStickerSet(int64_t chatId) const;
621 
622 
632  bool answerCallbackQuery(const std::string & callbackQueryId, const std::string & text="", bool showAlert=false, const std::string &url="", int32_t cacheTime=0) const;
633 
645  Message::Ptr editMessageText(const std::string& text, int64_t chatId=0, int32_t messageId=0, const std::string& inlineMessageId="",
646  const std::string& parseMode = "", bool disableWebPagePreview = false, const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
647 
657  Message::Ptr editMessageCaption(int64_t chatId = 0, int32_t messageId = 0, const std::string& caption = "",
658  const std::string& inlineMessageId = "", const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
659 
668  Message::Ptr editMessageReplyMarkup(int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "",
669  const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>()) const;
670 
676  void deleteMessage(int64_t chatId, int32_t messageId) const;
677 
690  std::vector<Update::Ptr> getUpdates(int32_t offset = 0, int32_t limit = 100, int32_t timeout = 0, const StringArrayPtr &allowedUpdates = nullptr) const;
691 
702  void setWebhook(const std::string& url = "", const InputFile::Ptr certificate = nullptr, int32_t maxConnection = 40, const StringArrayPtr &allowedUpdates = nullptr) const;
703 
711  bool deleteWebhook() const;
712 
722 
735  bool answerInlineQuery(const std::string& inlineQueryId, const std::vector<InlineQueryResult::Ptr>& results,
736  int32_t cacheTime = 300, bool isPersonal = false, const std::string& nextOffset = "", const std::string& switchPmText = "", const std::string& switchPmParameter = "") const;
737 
745  bool kickChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0) const;
746 
753  bool unbanChatMember(int64_t chatId, int32_t userId) const;
754 
766  bool restrictChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0, bool canSendMessages = false,
767  bool canSendMediaMessages = false, bool canSendOtherMessages = false, bool canAddWebPagePreviews = false) const;
768 
783  bool promoteChatMember(int64_t chatId, int32_t userId, bool canChangeInfo = false, bool canPostMessages = false,
784  bool canEditMessages = false, bool canDeleteMessages = false, bool canInviteUsers = false, bool canPinMessages = false, bool canPromoteMembers = false) const;
785 
791  std::string exportChatInviteLink(int64_t chatId) const;
792 
802  bool setChatPhoto(int64_t chatId, const InputFile::Ptr photo) const;
803 
812  bool deleteChatPhoto(int64_t chatId) const;
813 
823  bool setChatTitle(int64_t chatId, const std::string& title) const;
824 
831  bool setChatDescription(int64_t chatId, const std::string& description) const;
832 
840  bool pinChatMessage(int64_t chatId, int32_t messageId, bool disableNotification = false) const;
841 
847  bool unpinChatMessage(int64_t chatId) const;
848 
863  Message::Ptr setGameScore(int32_t userId, int32_t score, bool force = false, bool disableEditMessage = false,
864  int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "") const;
865 
877  std::vector<GameHighScore::Ptr> getGameHighScores(int32_t userId, int32_t score, bool force = false,
878  bool disableEditMessage = false, int64_t chatId = 0, int32_t messageId = 0, const std::string& inlineMessageId = "") const;
879 
880 
887  std::string downloadFile(const std::string& filePath, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const;
888 
889 private:
890  boost::property_tree::ptree sendRequest(const std::string& method, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const;
891 
892  const std::string _token;
893 };
894 
895 }
896 
897 #endif //TGBOT_CPP_API_H
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.
std::shared_ptr< StickerSet > Ptr
Definition: StickerSet.h:42
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.
std::shared_ptr< File > Ptr
Definition: File.h:26
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...
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::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...
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 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...
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)...
Definition: Api.h:49
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. ...
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...
bool unbanChatMember(int64_t chatId, int32_t userId) const
Use this method to unban a previously kicked user in a supergroup.
std::shared_ptr< InlineKeyboardMarkup > Ptr
int32_t getChatMembersCount(int64_t chatId) const
Use this method to get the number of members in a chat. Returns Int on success.
StickerSet::Ptr getStickerSet(const std::string &name) const
Use this method to get a sticker set.
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.
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.
This class executes telegram api methods. Telegram docs: https://core.telegram.org/bots/api#available...
Definition: Api.h:58
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.
std::shared_ptr< Message > Ptr
Definition: Message.h:56
bool setChatDescription(int64_t chatId, const std::string &description) const
Use this method to change the description of a supergroup or a channel.
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...
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.
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...
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...
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...
Message::Ptr sendInvoice(int64_t chatId, const std::string &title, const std::string &description, const std::string &payload, const std::string &providerToken, const std::string &startParameter, const std::string &currency, const std::vector< LabeledPrice::Ptr > &prices, const std::string &providerData="", const std::string &photoUrl="", int32_t photoSize=0, int32_t photoWidth=0, int32_t photoHeight=0, bool needName=false, bool needPhoneNumber=false, bool needEmail=false, bool needShippingAddress=false, bool sendPhoneNumberToProvider=false, bool sendEmailToProvider=false, bool isFlexible=false, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >(), bool disableNotification=false) const
Use this method to send invoices.
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...
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).
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...
std::shared_ptr< UserProfilePhotos > Ptr
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.
std::shared_ptr< WebhookInfo > Ptr
Definition: WebhookInfo.h:21
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)...
This object holds other objects specific for this bot instance.
Definition: Bot.h:39
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) ...
std::shared_ptr< GenericReply > Ptr
Definition: GenericReply.h:37
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.
std::shared_ptr< InputFile > Ptr
Definition: InputFile.h:40
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&#39;s side...
std::shared_ptr< Chat > Ptr
Definition: Chat.h:41
bool deleteChatPhoto(int64_t chatId) const
Use this method to delete a chat photo.
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.
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. ...
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.
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.
bool unpinChatMessage(int64_t chatId) const
Use this method to unpin a message in a supergroup or a channel.
bool deleteWebhook() const
Use this method to remove webhook integration if you decide to switch back to getUpdates.
std::shared_ptr< MaskPosition > Ptr
Definition: MaskPosition.h:39
User::Ptr getMe() const
A simple method for testing your bot&#39;s auth token.
bool answerPreCheckoutQuery(const std::string &preCheckoutQueryId, bool ok, const std::string &errorMessage="") const
Use this method to respond to such pre-checkout queries.
Api(const std::string &token)
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 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.
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 answerShippingQuery(const std::string &shippingQueryId, bool ok, const std::vector< ShippingOption::Ptr > &shippingOptions=std::vector< ShippingOption::Ptr >(), const std::string &errorMessage="") const
Use this method to reply to shipping queries.
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 ...
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.
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.
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.
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.
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.
bool setChatTitle(int64_t chatId, const std::string &title) const
Use this method to change the title of a chat.
std::shared_ptr< ChatMember > Ptr
Definition: ChatMember.h:22
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 setChatPhoto(int64_t chatId, const InputFile::Ptr photo) const
Use this method to set a new profile photo for the chat.
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 deleteStickerPositionInSet(const std::string &sticker) const
Use this method to delete a sticker from a set created by the bot.
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.
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.
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...
WebhookInfo::Ptr getWebhookInfo() const
Use this method to get current webhook status.
std::shared_ptr< User > Ptr
Definition: User.h:39
bool leaveChat(int64_t chatId) const
Use this method for your bot to leave a group, supergroup or channel.