tgbotxx  1.0.6.9
Telegram Bot C++ Library
Api.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <cpr/cpr.h>
3 #include <cstdint>
4 #include <functional>
5 #include <nlohmann/json.hpp>
6 #include <optional>
7 #include <string>
9 #include <tgbotxx/utils/Ptr.hpp>
11 #include <variant>
12 namespace nl = nlohmann;
13 
14 namespace tgbotxx {
16  struct User;
17  struct Message;
18  struct Update;
19  struct Chat;
20  struct MessageEntity;
21  struct IReplyMarkup;
22  struct MessageId;
23  struct InputMedia;
24  struct UserProfilePhotos;
25  struct File;
26  struct ChatMember;
27  struct ChatPermissions;
28  struct ChatInviteLink;
29  struct Sticker;
30  struct ForumTopic;
31  struct BotCommand;
32  struct BotCommandScope;
33  struct BotName;
34  struct BotShortDescription;
35  struct BotDescription;
36  struct InlineQueryResult;
38  struct MenuButton;
40  struct WebhookInfo;
41  struct Poll;
42  struct LabeledPrice;
43  struct ShippingOption;
44  struct SentWebAppMessage;
45  struct ReplyParameters;
46  struct StickerSet;
47  struct InputSticker;
48  struct MaskPosition;
49  struct PassportElementError;
50  struct GameHighScore;
51  struct ReactionType;
52 
56  class Api {
57  static const std::string DEFAULT_API_URL;
58  static const cpr::ConnectTimeout DEFAULT_CONNECT_TIMEOUT;
59  static const cpr::Timeout DEFAULT_TIMEOUT;
60  static const cpr::Timeout DEFAULT_LONG_POLL_TIMEOUT;
61  static const cpr::Timeout DEFAULT_UPLOAD_FILES_TIMEOUT;
62  static const cpr::Timeout DEFAULT_DOWNLOAD_FILES_TIMEOUT;
63 
64  const std::string m_token;
65  std::string m_apiUrl = DEFAULT_API_URL;
66  cpr::ConnectTimeout m_connectTimeout = DEFAULT_CONNECT_TIMEOUT;
67  cpr::Timeout m_timeout = DEFAULT_TIMEOUT;
68  cpr::Timeout m_longPollTimeout = DEFAULT_LONG_POLL_TIMEOUT;
69  cpr::Timeout m_uploadFilesTimeout = DEFAULT_UPLOAD_FILES_TIMEOUT;
70  cpr::Timeout m_downloadFilesTimeout = DEFAULT_DOWNLOAD_FILES_TIMEOUT;
71  std::vector<std::string> m_allowedUpdates;
75 
76 
77  friend class Bot;
78 
79  public:
82  explicit Api(const std::string& token);
83 
84  public:
88  Ptr<User> getMe() const;
89 
96  bool logOut() const;
97 
104  bool close() const;
105 
122  Ptr<Message> sendMessage(const std::variant<std::int64_t, std::string>& chatId,
123  const std::string& text,
124  std::int32_t messageThreadId = 0,
125  const std::string& parseMode = "",
126  const std::vector<Ptr<MessageEntity>>& entities = std::vector<Ptr<MessageEntity>>(),
127  bool disableWebPagePreview = false,
128  bool disableNotification = false,
129  bool protectContent = false,
130  std::int32_t replyToMessageId = 0,
131  bool allowSendingWithoutReply = false,
132  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
133 
144  Ptr<Message> forwardMessage(const std::variant<std::int64_t, std::string>& chatId,
145  const std::variant<std::int64_t, std::string>& fromChatId,
146  std::int32_t messageId,
147  std::int32_t messageThreadId = 0,
148  bool disableNotification = false,
149  bool protectContent = false) const;
150 
171  Ptr<MessageId> copyMessage(const std::variant<std::int64_t, std::string>& chatId,
172  const std::variant<std::int64_t, std::string>& fromChatId,
173  std::int32_t messageId,
174  std::int32_t messageThreadId = 0,
175  const std::string& caption = "",
176  const std::string& parseMode = "",
177  const std::vector<Ptr<MessageEntity>>& captionEntities = std::vector<Ptr<MessageEntity>>(),
178  bool disableNotification = false,
179  bool protectContent = false,
180  std::int32_t replyToMessageId = 0,
181  bool allowSendingWithoutReply = false,
182  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
183 
205  Ptr<Message> sendPhoto(const std::variant<std::int64_t, std::string>& chatId,
206  const std::variant<cpr::File, std::string>& photo,
207  std::int32_t messageThreadId = 0,
208  const std::string& caption = "",
209  const std::string& parseMode = "",
210  const std::vector<Ptr<MessageEntity>>& captionEntities = std::vector<Ptr<MessageEntity>>(),
211  bool disableNotification = false,
212  bool protectContent = false,
213  std::int32_t replyToMessageId = 0,
214  bool allowSendingWithoutReply = false,
215  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
216 
247  Ptr<Message> sendAudio(const std::variant<std::int64_t, std::string>& chatId,
248  const std::variant<cpr::File, std::string>& audio,
249  std::int32_t messageThreadId = 0,
250  const std::string& caption = "",
251  const std::string& parseMode = "",
252  const std::vector<Ptr<MessageEntity>>& captionEntities = std::vector<Ptr<MessageEntity>>(),
253  std::int32_t duration = 0,
254  const std::string& performer = "",
255  const std::string& title = "",
256  const std::optional<std::variant<cpr::File, std::string>>& thumbnail = std::nullopt,
257  bool disableNotification = false,
258  bool protectContent = false,
259  std::int32_t replyToMessageId = 0,
260  bool allowSendingWithoutReply = false,
261  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
262 
263 
290  Ptr<Message> sendDocument(const std::variant<std::int64_t, std::string>& chatId,
291  const std::variant<cpr::File, std::string>& document,
292  std::int32_t messageThreadId = 0,
293  const std::optional<std::variant<cpr::File, std::string>>& thumbnail = std::nullopt,
294  const std::string& caption = "",
295  const std::string& parseMode = "",
296  const std::vector<Ptr<MessageEntity>>& captionEntities = std::vector<Ptr<MessageEntity>>(),
297  bool disableNotification = false,
298  bool protectContent = false,
299  std::int32_t replyToMessageId = 0,
300  bool allowSendingWithoutReply = false,
301  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
302 
303 
335  Ptr<Message> sendVideo(const std::variant<std::int64_t, std::string>& chatId,
336  const std::variant<cpr::File, std::string>& video,
337  std::int32_t messageThreadId = 0,
338  std::int32_t duration = 0,
339  std::int32_t width = 0,
340  std::int32_t height = 0,
341  const std::optional<std::variant<cpr::File, std::string>>& thumbnail = std::nullopt,
342  const std::string& caption = "",
343  const std::string& parseMode = "",
344  const std::vector<Ptr<MessageEntity>>& captionEntities = std::vector<Ptr<MessageEntity>>(),
345  bool hasSpoiler = false,
346  bool supportsStreaming = false,
347  bool disableNotification = false,
348  bool protectContent = false,
349  std::int32_t replyToMessageId = 0,
350  bool allowSendingWithoutReply = false,
351  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
352 
353 
384  Ptr<Message> sendAnimation(const std::variant<std::int64_t, std::string>& chatId,
385  const std::variant<cpr::File, std::string>& animation,
386  std::int32_t messageThreadId = 0,
387  std::int32_t duration = 0,
388  std::int32_t width = 0,
389  std::int32_t height = 0,
390  const std::optional<std::variant<cpr::File, std::string>>& thumbnail = std::nullopt,
391  const std::string& caption = "",
392  const std::string& parseMode = "",
393  const std::vector<Ptr<MessageEntity>>& captionEntities = std::vector<Ptr<MessageEntity>>(),
394  bool hasSpoiler = false,
395  bool disableNotification = false,
396  bool protectContent = false,
397  std::int32_t replyToMessageId = 0,
398  bool allowSendingWithoutReply = false,
399  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
400 
401 
425  Ptr<Message> sendVoice(const std::variant<std::int64_t, std::string>& chatId,
426  const std::variant<cpr::File, std::string>& voice,
427  std::int32_t messageThreadId = 0,
428  const std::string& caption = "",
429  const std::string& parseMode = "",
430  const std::vector<Ptr<MessageEntity>>& captionEntities = std::vector<Ptr<MessageEntity>>(),
431  std::int32_t duration = 0,
432  bool disableNotification = false,
433  bool protectContent = false,
434  std::int32_t replyToMessageId = 0,
435  bool allowSendingWithoutReply = false,
436  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
437 
438 
465  Ptr<Message> sendVideoNote(const std::variant<std::int64_t, std::string>& chatId,
466  const std::variant<cpr::File, std::string>& videoNote,
467  std::int32_t messageThreadId = 0,
468  std::int32_t duration = 0,
469  std::int32_t length = 0,
470  const std::optional<std::variant<cpr::File, std::string>>& thumbnail = std::nullopt,
471  bool disableNotification = false,
472  bool protectContent = false,
473  std::int32_t replyToMessageId = 0,
474  bool allowSendingWithoutReply = false,
475  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
476 
477 
493  std::vector<Ptr<Message>> sendMediaGroup(const std::variant<std::int64_t, std::string>& chatId,
494  const std::vector<Ptr<InputMedia>>& media,
495  std::int32_t messageThreadId = 0,
496  bool disableNotification = false,
497  bool protectContent = false,
498  std::int32_t replyToMessageId = 0,
499  bool allowSendingWithoutReply = false) const;
500 
501 
520  Ptr<Message> sendLocation(const std::variant<std::int64_t, std::string>& chatId,
521  float latitude,
522  float longitude,
523  std::int32_t messageThreadId = 0,
524  float horizontalAccuracy = 0.0f,
525  std::int32_t livePeriod = 0,
526  std::int32_t heading = 0,
527  std::int32_t proximityAlertRadius = 0,
528  bool disableNotification = false,
529  bool protectContent = false,
530  std::int32_t replyToMessageId = 0,
531  bool allowSendingWithoutReply = false,
532  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
533 
534 
555  Ptr<Message> sendVenue(const std::variant<std::int64_t, std::string>& chatId,
556  float latitude,
557  float longitude,
558  const std::string& title,
559  const std::string& address,
560  std::int32_t messageThreadId = 0,
561  const std::string& foursquareId = "",
562  const std::string& foursquareType = "",
563  const std::string& googlePlaceId = "",
564  const std::string& googlePlaceType = "",
565  bool disableNotification = false,
566  bool protectContent = false,
567  std::int32_t replyToMessageId = 0,
568  bool allowSendingWithoutReply = false,
569  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
570 
571 
588  Ptr<Message> sendContact(const std::variant<std::int64_t, std::string>& chatId,
589  const std::string& phoneNumber,
590  const std::string& firstName,
591  const std::string& lastName = "",
592  const std::string& vcard = "",
593  std::int32_t messageThreadId = 0,
594  bool disableNotification = false,
595  bool protectContent = false,
596  std::int32_t replyToMessageId = 0,
597  bool allowSendingWithoutReply = false,
598  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
599 
600 
625  Ptr<Message> sendPoll(const std::variant<std::int64_t, std::string>& chatId,
626  const std::string& question,
627  const std::vector<std::string>& options,
628  bool isAnonymous = true,
629  const std::string& type = "regular",
630  bool allowsMultipleAnswers = false,
631  std::int32_t correctOptionId = -1,
632  const std::string& explanation = "",
633  const std::string& explanationParseMode = "",
634  const std::vector<Ptr<MessageEntity>>& explanationEntities = std::vector<Ptr<MessageEntity>>(),
635  std::int32_t openPeriod = 0,
636  std::int32_t closeDate = 0,
637  bool isClosed = false,
638  std::int32_t messageThreadId = 0,
639  bool disableNotification = false,
640  bool protectContent = false,
641  std::int32_t replyToMessageId = 0,
642  bool allowSendingWithoutReply = false,
643  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
644 
645 
660  Ptr<Message> sendDice(const std::variant<std::int64_t, std::string>& chatId,
661  const std::string& emoji = "🎲",
662  std::int32_t messageThreadId = 0,
663  bool disableNotification = false,
664  bool protectContent = false,
665  std::int32_t replyToMessageId = 0,
666  bool allowSendingWithoutReply = false,
667  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
668 
669 
691  bool sendChatAction(const std::variant<std::int64_t, std::string>& chatId,
692  const std::string& action,
693  std::int32_t messageThreadId = 0) const;
694 
695 
707  bool setMessageReaction(const std::variant<std::int64_t, std::string>& chatId,
708  std::int32_t messageId,
709  const std::vector<Ptr<ReactionType>>& reaction = std::vector<Ptr<ReactionType>>(),
710  bool isBig = false) const;
711 
712 
721  std::int32_t offset = 0,
722  std::int32_t limit = 100) const;
723 
724 
734  Ptr<File> getFile(const std::string& fileId) const;
735 
736 
746  std::string downloadFile(const std::string& filePath, const std::function<bool(cpr::cpr_off_t downloadTotal, cpr::cpr_off_t downloadNow)>& progressCallback = nullptr) const;
747 
748 
761  bool banChatMember(const std::variant<std::int64_t, std::string>& chatId,
762  std::int64_t userId,
763  std::time_t untilDate = 0,
764  bool revokeMessages = false) const;
765 
766 
778  bool unbanChatMember(const std::variant<std::int64_t, std::string>& chatId,
779  std::int64_t userId,
780  bool onlyIfBanned = false) const;
781 
782 
796  bool restrictChatMember(const std::variant<std::int64_t, std::string>& chatId,
797  std::int64_t userId,
798  const Ptr<ChatPermissions>& permissions,
799  bool useIndependentChatPermissions = false,
800  std::time_t untilDate = 0) const;
801 
802 
827  bool promoteChatMember(const std::variant<std::int64_t, std::string>& chatId,
828  std::int64_t userId,
829  bool isAnonymous = false,
830  bool canManageChat = false,
831  bool canDeleteMessages = false,
832  bool canManageVideoChats = false,
833  bool canRestrictMembers = false,
834  bool canPromoteMembers = false,
835  bool canChangeInfo = false,
836  bool canInviteUsers = false,
837  bool canPostMessages = false,
838  bool canEditMessages = false,
839  bool canPinMessages = false,
840  bool canPostStories = false,
841  bool canEditStories = false,
842  bool canDeleteStories = false,
843  bool canManageTopics = false) const;
844 
845 
853  bool setChatAdministratorCustomTitle(const std::variant<std::int64_t, std::string>& chatId,
854  std::int64_t userId,
855  const std::string& customTitle) const;
856 
857 
868  bool banChatSenderChat(const std::variant<std::int64_t, std::string>& chatId,
869  std::int64_t senderChatId) const;
870 
871 
881  bool unbanChatSenderChat(const std::variant<std::int64_t, std::string>& chatId,
882  std::int64_t senderChatId) const;
883 
884 
896  bool setChatPermissions(const std::variant<std::int64_t, std::string>& chatId,
897  const Ptr<ChatPermissions>& permissions,
898  bool useIndependentChatPermissions = false) const;
899 
900 
915  std::string exportChatInviteLink(const std::variant<std::int64_t, std::string>& chatId) const;
916 
917 
930  Ptr<ChatInviteLink> createChatInviteLink(const std::variant<std::int64_t, std::string>& chatId,
931  const std::string& name = "",
932  std::time_t expireDate = 0,
933  std::int32_t memberLimit = 0,
934  bool createsJoinRequest = false) const;
935 
936 
949  Ptr<ChatInviteLink> editChatInviteLink(const std::variant<std::int64_t, std::string>& chatId,
950  const std::string& inviteLink,
951  const std::string& name = "",
952  std::time_t expireDate = 0,
953  std::int32_t memberLimit = 0,
954  bool createsJoinRequest = false) const;
955 
956 
965  Ptr<ChatInviteLink> revokeChatInviteLink(const std::variant<std::int64_t, std::string>& chatId, const std::string& inviteLink) const;
966 
967 
976  bool approveChatJoinRequest(const std::variant<std::int64_t, std::string>& chatId, std::int64_t userId) const;
977 
978 
987  bool declineChatJoinRequest(const std::variant<std::int64_t, std::string>& chatId, std::int64_t userId) const;
988 
989 
998  bool setChatPhoto(const std::variant<std::int64_t, std::string>& chatId, const cpr::File& photo) const;
999 
1000 
1008  bool deleteChatPhoto(const std::variant<std::int64_t, std::string>& chatId) const;
1009 
1010 
1018  bool setChatTitle(const std::variant<std::int64_t, std::string>& chatId, const std::string& title) const;
1019 
1020 
1028  bool setChatDescription(const std::variant<std::int64_t, std::string>& chatId, const std::string& description = "") const;
1029 
1030 
1042  bool pinChatMessage(const std::variant<std::int64_t, std::string>& chatId,
1043  std::int32_t messageId,
1044  bool disableNotification = false) const;
1045 
1046 
1056  bool unpinChatMessage(const std::variant<std::int64_t, std::string>& chatId, std::int32_t messageId = 0) const;
1057 
1058 
1067  bool unpinAllChatMessages(const std::variant<std::int64_t, std::string>& chatId) const;
1068 
1069 
1075  bool leaveChat(const std::variant<std::int64_t, std::string>& chatId) const;
1076 
1077 
1083  Ptr<Chat> getChat(const std::variant<std::int64_t, std::string>& chatId) const;
1084 
1085 
1091  std::vector<Ptr<ChatMember>> getChatAdministrators(const std::variant<std::int64_t, std::string>& chatId) const;
1092 
1093 
1099  std::int32_t getChatMemberCount(const std::variant<std::int64_t, std::string>& chatId) const;
1100 
1101 
1109  Ptr<ChatMember> getChatMember(const std::variant<std::int64_t, std::string>& chatId, std::int64_t userId) const;
1110 
1111 
1121  bool setChatStickerSet(const std::variant<std::int64_t, std::string>& chatId, const std::string& stickerSetName) const;
1122 
1123 
1132  bool deleteChatStickerSet(const std::variant<std::int64_t, std::string>& chatId) const;
1133 
1134 
1142  std::vector<Ptr<Sticker>> getForumTopicIconStickers() const;
1143 
1144 
1156  Ptr<ForumTopic> createForumTopic(const std::variant<std::int64_t, std::string>& chatId,
1157  const std::string& name,
1158  std::int32_t iconColor = 0x000000,
1159  const std::string& iconCustomEmojiId = "") const;
1160 
1161 
1175  bool editForumTopic(const std::variant<std::int64_t, std::string>& chatId,
1176  std::int32_t messageThreadId,
1177  const std::string& name,
1178  const std::optional<std::string>& iconCustomEmojiId = std::nullopt) const;
1179 
1180 
1190  bool closeForumTopic(const std::variant<std::int64_t, std::string>& chatId, std::int32_t messageThreadId) const;
1191 
1192 
1202  bool reopenForumTopic(const std::variant<std::int64_t, std::string>& chatId, std::int32_t messageThreadId) const;
1203 
1204 
1214  bool deleteForumTopic(const std::variant<std::int64_t, std::string>& chatId, std::int32_t messageThreadId) const;
1215 
1216 
1225  bool unpinAllForumTopicMessages(const std::variant<std::int64_t, std::string>& chatId, std::int32_t messageThreadId) const;
1226 
1227 
1235  bool editGeneralForumTopic(const std::variant<std::int64_t, std::string>& chatId, const std::string& name) const;
1236 
1237 
1244  bool closeGeneralForumTopic(const std::variant<std::int64_t, std::string>& chatId) const;
1245 
1246 
1253  bool reopenGeneralForumTopic(const std::variant<std::int64_t, std::string>& chatId) const;
1254 
1255 
1262  bool hideGeneralForumTopic(const std::variant<std::int64_t, std::string>& chatId) const;
1263 
1264 
1271  bool unhideGeneralForumTopic(const std::variant<std::int64_t, std::string>& chatId) const;
1272 
1273 
1280  bool unpinAllGeneralForumTopicMessages(const std::variant<std::int64_t, std::string>& chatId) const;
1281 
1282 
1299  bool answerCallbackQuery(const std::string& callbackQueryId,
1300  const std::string& text = "",
1301  bool showAlert = false,
1302  const std::string& url = "",
1303  std::int32_t cacheTime = 0) const;
1304 
1305 
1315  bool setMyCommands(const std::vector<Ptr<BotCommand>>& commands,
1316  const Ptr<BotCommandScope>& scope = nullptr,
1317  const std::string& languageCode = "") const;
1318 
1319 
1328  bool deleteMyCommands(const Ptr<BotCommandScope>& scope = nullptr, const std::string& languageCode = "") const;
1329 
1330 
1337  std::vector<Ptr<BotCommand>> getMyCommands(const Ptr<BotCommandScope>& scope = nullptr, const std::string& languageCode = "") const;
1338 
1339 
1346  bool setMyName(const std::string& name = "", const std::string& languageCode = "") const;
1347 
1348 
1354  Ptr<BotName> getMyName(const std::string& languageCode = "") const;
1355 
1356 
1363  bool setMyDescription(const std::string& description = "", const std::string& languageCode = "") const;
1364 
1365 
1371  Ptr<BotDescription> getMyDescription(const std::string& languageCode = "") const;
1372 
1379  bool setMyShortDescription(const std::string& shortDescription = "", const std::string& languageCode = "") const;
1380 
1386  Ptr<BotShortDescription> getMyShortDescription(const std::string& languageCode = "") const;
1387 
1394  bool setChatMenuButton(const std::variant<std::int64_t, std::string>& chatId = std::string{}, const Ptr<MenuButton>& menuButton = nullptr) const;
1395 
1401  Ptr<MenuButton> getChatMenuButton(const std::variant<std::int64_t, std::string>& chatId = std::string{}) const;
1402 
1410  bool setMyDefaultAdministratorRights(const Ptr<ChatAdministratorRights>& rights = nullptr, bool forChannels = false) const;
1411 
1418 
1419 
1420  public:
1458  Ptr<Message> sendInvoice(const std::variant<std::int64_t, std::string>& chatId,
1459  const std::string& title,
1460  const std::string& description,
1461  const std::string& payload,
1462  const std::string& providerToken,
1463  const std::string& currency,
1464  const std::vector<Ptr<LabeledPrice>>& prices,
1465  std::int32_t messageThreadId = 0,
1466  std::int32_t maxTipAmount = 0,
1467  const std::vector<std::int32_t>& suggestedTipAmounts = std::vector<std::int32_t>(),
1468  const std::string& startParameter = "",
1469  const std::string& providerData = "",
1470  const std::string& photoUrl = "",
1471  std::int32_t photoSize = 0,
1472  std::int32_t photoWidth = 0,
1473  std::int32_t photoHeight = 0,
1474  bool needName = false,
1475  bool needPhoneNumber = false,
1476  bool needEmail = false,
1477  bool needShippingAddress = false,
1478  bool sendPhoneNumberToProvider = false,
1479  bool sendEmailToProvider = false,
1480  bool isFlexible = false,
1481  bool disableNotification = false,
1482  bool protectContent = false,
1483  std::int32_t replyToMessageId = 0,
1484  bool allowSendingWithoutReply = false,
1485  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
1486 
1516  std::string createInvoiceLink(const std::string& title,
1517  const std::string& description,
1518  const std::string& payload,
1519  const std::string& providerToken,
1520  const std::string& currency,
1521  const std::vector<Ptr<LabeledPrice>>& prices,
1522  std::int32_t maxTipAmount = 0,
1523  const std::vector<std::int32_t>& suggestedTipAmounts = std::vector<std::int32_t>(),
1524  const std::string& providerData = "",
1525  const std::string& photoUrl = "",
1526  std::int32_t photoSize = 0,
1527  std::int32_t photoWidth = 0,
1528  std::int32_t photoHeight = 0,
1529  bool needName = false,
1530  bool needPhoneNumber = false,
1531  bool needEmail = false,
1532  bool needShippingAddress = false,
1533  bool sendPhoneNumberToProvider = false,
1534  bool sendEmailToProvider = false,
1535  bool isFlexible = false) const;
1536 
1537 
1549  bool answerShippingQuery(const std::string& shippingQueryId,
1550  bool ok,
1551  const std::vector<Ptr<ShippingOption>>& shippingOptions = std::vector<Ptr<ShippingOption>>(),
1552  const std::string& errorMessage = "") const;
1553 
1554 
1566  bool answerPreCheckoutQuery(const std::string& preCheckoutQueryId,
1567  bool ok,
1568  const std::string& errorMessage = "") const;
1569 
1570 
1571  public:
1587  std::vector<Ptr<Update>> getUpdates(std::int32_t offset, std::int32_t limit = 100) const;
1588 
1614  bool setWebhook(const std::string& url,
1615  const std::optional<cpr::File>& certificate = std::nullopt,
1616  const std::string& ipAddress = "",
1617  std::int32_t maxConnections = 40,
1618  const std::vector<std::string>& allowedUpdates = std::vector<std::string>(),
1619  bool dropPendingUpdates = false,
1620  const std::string& secretToken = "") const;
1621 
1629  bool deleteWebhook(bool dropPendingUpdates = false) const;
1630 
1637 
1638  public:
1654  Ptr<Message> editMessageText(const std::string& text,
1655  const std::variant<std::int64_t, std::string>& chatId = 0,
1656  std::int32_t messageId = 0,
1657  const std::string& inlineMessageId = "",
1658  const std::string& parseMode = "",
1659  const std::vector<Ptr<MessageEntity>>& entities = std::vector<Ptr<MessageEntity>>(),
1660  bool disableWebPagePreview = false,
1661  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
1662 
1663 
1674  Ptr<Message> editMessageCaption(const std::variant<std::int64_t, std::string>& chatId = 0,
1675  std::int32_t messageId = 0,
1676  const std::string& inlineMessageId = "",
1677  const std::string& caption = "",
1678  const std::string& parseMode = "",
1679  const std::vector<Ptr<MessageEntity>>& captionEntities = std::vector<Ptr<MessageEntity>>(),
1680  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
1681 
1682 
1694  const std::variant<std::int64_t, std::string>& chatId = 0,
1695  std::int32_t messageId = 0,
1696  const std::string& inlineMessageId = "",
1697  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
1698 
1699 
1714  float longitude,
1715  const std::variant<std::int64_t, std::string>& chatId = 0,
1716  std::int32_t messageId = 0,
1717  const std::string& inlineMessageId = "",
1718  float horizontalAccuracy = 0.0f,
1719  std::int32_t heading = 0,
1720  std::int32_t proximityAlertRadius = 0,
1721  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
1722 
1723 
1731  Ptr<Message> stopMessageLiveLocation(const std::variant<std::int64_t, std::string>& chatId = 0,
1732  std::int32_t messageId = 0,
1733  const std::string& inlineMessageId = "",
1734  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
1735 
1736 
1744  Ptr<Message> editMessageReplyMarkup(const std::variant<std::int64_t, std::string>& chatId = 0,
1745  std::int32_t messageId = 0,
1746  const std::string& inlineMessageId = "",
1747  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
1748 
1749 
1756  Ptr<Poll> stopPoll(const std::variant<std::int64_t, std::string>& chatId,
1757  std::int32_t messageId,
1758  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
1759 
1760 
1775  bool deleteMessage(const std::variant<std::int64_t, std::string>& chatId, std::int32_t messageId) const;
1776 
1777  public:
1794  Ptr<Message> sendSticker(const std::variant<std::int64_t, std::string>& chatId,
1795  const std::variant<cpr::File, std::string>& sticker,
1796  std::int32_t messageThreadId = 0,
1797  const std::string& emoji = "",
1798  bool disableNotification = false,
1799  bool protectContent = false,
1800  const Ptr<ReplyParameters>& replyParameters = nullptr,
1801  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
1802 
1808  Ptr<StickerSet> getStickerSet(const std::string& name) const;
1809 
1815  std::vector<Ptr<Sticker>> getCustomEmojiStickers(const std::vector<std::string>& customEmojiIds) const;
1816 
1826  Ptr<File> uploadStickerFile(std::int64_t userId,
1827  const cpr::File& sticker,
1828  const std::string& stickerFormat) const;
1829 
1845  bool createNewStickerSet(std::int64_t userId,
1846  const std::string& name,
1847  const std::string& title,
1848  const std::vector<Ptr<InputSticker>>& stickers,
1849  const std::string& stickerFormat,
1850  const std::string& stickerType = "regular",
1851  bool needsRepainting = false) const;
1852 
1863  bool addStickerToSet(std::int64_t userId,
1864  const std::string& name,
1865  const Ptr<InputSticker>& sticker) const;
1866 
1873  bool setStickerPositionInSet(const std::string& sticker, std::int32_t position) const;
1874 
1880  bool deleteStickerFromSet(const std::string& sticker) const;
1881 
1889  bool setStickerEmojiList(const std::string& sticker, const std::vector<std::string>& emojiList) const;
1890 
1898  bool setStickerKeywords(const std::string& sticker, const std::vector<std::string>& keywords = std::vector<std::string>()) const;
1899 
1907  bool setStickerMaskPosition(const std::string& sticker,
1908  const Ptr<MaskPosition>& maskPosition = nullptr) const;
1909 
1916  bool setStickerSetTitle(const std::string& name, const std::string& title) const;
1917 
1933  bool setStickerSetThumbnail(const std::string& name,
1934  const std::string& title,
1935  const std::optional<std::variant<cpr::File, std::string>>& thumbnail = std::nullopt) const;
1936 
1944  bool setCustomEmojiStickerSetThumbnail(const std::string& name, const std::optional<std::string>& customEmojiId = std::nullopt) const;
1945 
1951  bool deleteStickerSet(const std::string& name) const;
1952 
1953  public:
1965  bool setPassportDataErrors(std::int64_t userId, const std::vector<Ptr<PassportElementError>>& errors) const;
1966 
1967  public:
1980  Ptr<Message> sendGame(const std::variant<std::int64_t, std::string>& chatId,
1981  const std::string& gameShortName,
1982  std::int32_t messageThreadId = 0,
1983  bool disableNotification = false,
1984  bool protectContent = false,
1985  const Ptr<ReplyParameters>& replyParameters = nullptr,
1986  const Ptr<IReplyMarkup>& replyMarkup = nullptr) const;
1987 
1999  Ptr<Message> setGameScore(std::int64_t userId,
2000  std::int32_t score,
2001  bool force = false,
2002  bool disableEditMessage = false,
2003  std::int64_t chatId = 0,
2004  std::int32_t messageId = 0,
2005  const std::string& inlineMessageId = "") const;
2006 
2007 
2019  std::vector<Ptr<GameHighScore>> getGameHighScores(std::int64_t userId,
2020  std::int64_t chatId = 0,
2021  std::int32_t messageId = 0,
2022  const std::string& inlineMessageId = "") const;
2023 
2024  public:
2038  bool answerInlineQuery(const std::string& inlineQueryId,
2039  const std::vector<Ptr<InlineQueryResult>>& results,
2040  std::int32_t cacheTime = 300,
2041  bool isPersonal = false,
2042  const std::string& nextOffset = "",
2043  const Ptr<InlineQueryResultsButton>& button = nullptr) const;
2044 
2045 
2053  Ptr<SentWebAppMessage> answerWebAppQuery(const std::string& webAppQueryId, const Ptr<InlineQueryResult>& result) const;
2054 
2055  public:
2057  void setUrl(const std::string& url) noexcept;
2059  const std::string& getUrl() const noexcept;
2060 
2062  void setLongPollTimeout(const cpr::Timeout& longPollTimeout);
2064  cpr::Timeout getLongPollTimeout() const noexcept;
2065 
2067  void setConnectTimeout(const cpr::ConnectTimeout& timeout) noexcept;
2069  cpr::ConnectTimeout getConnectTimeout() const noexcept;
2070 
2072  void setTimeout(const cpr::Timeout& timeout);
2074  cpr::Timeout getTimeout() const noexcept;
2075 
2077  void setUploadFilesTimeout(const cpr::Timeout& timeout) noexcept;
2079  cpr::Timeout getUploadFilesTimeout() const noexcept;
2080 
2082  void setDownloadFilesTimeout(const cpr::Timeout& timeout) noexcept;
2084  cpr::Timeout getDownloadFilesTimeout() const noexcept;
2085 
2090  void setAllowedUpdates(const std::vector<std::string>& allowedUpdates) noexcept;
2092  const std::vector<std::string>& getAllowedUpdates() const noexcept;
2093 
2094  private:
2095  nl::json sendRequest(const std::string& endpoint, const cpr::Multipart& data = cpr::Multipart({})) const;
2096  };
2097 }
Api Methods https://core.telegram.org/bots/api#available-methods.
Definition: Api.hpp:56
bool logOut() const
Use this method to log out from the cloud Bot API server before launching the bot locally....
bool setChatTitle(const std::variant< std::int64_t, std::string > &chatId, const std::string &title) const
Use this method to change the title of a chat. Titles can't be changed for private chats....
Ptr< ChatInviteLink > editChatInviteLink(const std::variant< std::int64_t, std::string > &chatId, const std::string &inviteLink, const std::string &name="", std::time_t expireDate=0, std::int32_t memberLimit=0, bool createsJoinRequest=false) const
Use this method to edit a non-primary invite link created by the bot. The bot must be an administrato...
bool reopenGeneralForumTopic(const std::variant< std::int64_t, std::string > &chatId) const
Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an adm...
cpr::Timeout getTimeout() const noexcept
Get Api requests timeout.
bool setChatPhoto(const std::variant< std::int64_t, std::string > &chatId, const cpr::File &photo) const
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats....
Ptr< Message > sendDocument(const std::variant< std::int64_t, std::string > &chatId, const std::variant< cpr::File, std::string > &document, std::int32_t messageThreadId=0, const std::optional< std::variant< cpr::File, std::string >> &thumbnail=std::nullopt, const std::string &caption="", const std::string &parseMode="", const std::vector< Ptr< MessageEntity >> &captionEntities=std::vector< Ptr< MessageEntity >>(), bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send general files.
bool setMessageReaction(const std::variant< std::int64_t, std::string > &chatId, std::int32_t messageId, const std::vector< Ptr< ReactionType >> &reaction=std::vector< Ptr< ReactionType >>(), bool isBig=false) const
Use this method to change the chosen reactions on a message. Service messages can't be reacted to....
std::vector< Ptr< ChatMember > > getChatAdministrators(const std::variant< std::int64_t, std::string > &chatId) const
Use this method to get a list of administrators in a chat, which aren't bots.
bool answerInlineQuery(const std::string &inlineQueryId, const std::vector< Ptr< InlineQueryResult >> &results, std::int32_t cacheTime=300, bool isPersonal=false, const std::string &nextOffset="", const Ptr< InlineQueryResultsButton > &button=nullptr) const
Use this method to send answers to an inline query. No more than 50 results per query are allowed.
void setUploadFilesTimeout(const cpr::Timeout &timeout) noexcept
Set Api file uploads timeout.
Ptr< Message > sendAudio(const std::variant< std::int64_t, std::string > &chatId, const std::variant< cpr::File, std::string > &audio, std::int32_t messageThreadId=0, const std::string &caption="", const std::string &parseMode="", const std::vector< Ptr< MessageEntity >> &captionEntities=std::vector< Ptr< MessageEntity >>(), std::int32_t duration=0, const std::string &performer="", const std::string &title="", const std::optional< std::variant< cpr::File, std::string >> &thumbnail=std::nullopt, bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send audio files, if you want Telegram clients to display them in the music player...
bool unbanChatSenderChat(const std::variant< std::int64_t, std::string > &chatId, std::int64_t senderChatId) const
Use this method to unban a previously banned channel chat in a supergroup or channel....
std::vector< Ptr< BotCommand > > getMyCommands(const Ptr< BotCommandScope > &scope=nullptr, const std::string &languageCode="") const
Use this method to get the current list of the bot's commands for the given scope and user language.
Ptr< SentWebAppMessage > answerWebAppQuery(const std::string &webAppQueryId, const Ptr< InlineQueryResult > &result) const
Use this method to set the result of an interaction with a Web App and send a corresponding message o...
bool setChatMenuButton(const std::variant< std::int64_t, std::string > &chatId=std::string{}, const Ptr< MenuButton > &menuButton=nullptr) const
Use this method to change the bot's menu button in a private chat, or the default menu button.
bool deleteStickerSet(const std::string &name) const
Use this method to delete a sticker set that was created by the bot.
void setTimeout(const cpr::Timeout &timeout)
Set Api requests timeout.
Ptr< BotDescription > getMyDescription(const std::string &languageCode="") const
Use this method to get the current bot description for the given user language.
bool setChatDescription(const std::variant< std::int64_t, std::string > &chatId, const std::string &description="") const
Use this method to change the description of a group, a supergroup or a channel. The bot must be an a...
Ptr< Poll > stopPoll(const std::variant< std::int64_t, std::string > &chatId, std::int32_t messageId, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to stop a poll which was sent by the bot.
Ptr< MenuButton > getChatMenuButton(const std::variant< std::int64_t, std::string > &chatId=std::string{}) const
Use this method to get the current value of the bot's menu button in a private chat,...
bool pinChatMessage(const std::variant< std::int64_t, std::string > &chatId, std::int32_t messageId, bool disableNotification=false) const
Use this method to add a message to the list of pinned messages in a chat. If the chat is not a priva...
Ptr< BotName > getMyName(const std::string &languageCode="") const
Use this method to get the current bot name for the given user language.
cpr::Timeout getDownloadFilesTimeout() const noexcept
Get Api file downloads timeout.
Ptr< MessageId > copyMessage(const std::variant< std::int64_t, std::string > &chatId, const std::variant< std::int64_t, std::string > &fromChatId, std::int32_t messageId, std::int32_t messageThreadId=0, const std::string &caption="", const std::string &parseMode="", const std::vector< Ptr< MessageEntity >> &captionEntities=std::vector< Ptr< MessageEntity >>(), bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to copy messages of any kind. Service messages and invoice messages can't be copied....
std::int32_t getChatMemberCount(const std::variant< std::int64_t, std::string > &chatId) const
Use this method to get the number of members in a chat.
Ptr< Message > setGameScore(std::int64_t userId, std::int32_t score, bool force=false, bool disableEditMessage=false, std::int64_t chatId=0, std::int32_t messageId=0, const std::string &inlineMessageId="") const
Use this method to set the score of the specified user in a game message.
bool setStickerPositionInSet(const std::string &sticker, std::int32_t position) const
Use this method to move a sticker in a set created by the bot to a specific position.
std::string createInvoiceLink(const std::string &title, const std::string &description, const std::string &payload, const std::string &providerToken, const std::string &currency, const std::vector< Ptr< LabeledPrice >> &prices, std::int32_t maxTipAmount=0, const std::vector< std::int32_t > &suggestedTipAmounts=std::vector< std::int32_t >(), const std::string &providerData="", const std::string &photoUrl="", std::int32_t photoSize=0, std::int32_t photoWidth=0, std::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) const
Use this method to create a link for an invoice. Returns the created invoice link as std::string on s...
bool sendChatAction(const std::variant< std::int64_t, std::string > &chatId, const std::string &action, std::int32_t messageThreadId=0) const
Use this method when you need to tell the user that something is happening on the bot's side....
void setAllowedUpdates(const std::vector< std::string > &allowedUpdates) noexcept
Ptr< Message > sendContact(const std::variant< std::int64_t, std::string > &chatId, const std::string &phoneNumber, const std::string &firstName, const std::string &lastName="", const std::string &vcard="", std::int32_t messageThreadId=0, bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send phone contacts.
Ptr< User > getMe() const
A simple method for testing your bot's authentication token.
Ptr< File > getFile(const std::string &fileId) const
Use this method to get basic information about a file and prepare it for downloading....
Api(const std::string &token)
Constructs Api object.
Ptr< Message > sendDice(const std::variant< std::int64_t, std::string > &chatId, const std::string &emoji="🎲", std::int32_t messageThreadId=0, bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send an animated emoji that will display a random value.
void setDownloadFilesTimeout(const cpr::Timeout &timeout) noexcept
Set Api file downloads timeout.
bool setChatPermissions(const std::variant< std::int64_t, std::string > &chatId, const Ptr< ChatPermissions > &permissions, bool useIndependentChatPermissions=false) const
Use this method to set default chat permissions for all members. The bot must be an administrator in ...
Ptr< Message > editMessageReplyMarkup(const std::variant< std::int64_t, std::string > &chatId=0, std::int32_t messageId=0, const std::string &inlineMessageId="", const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to edit only the reply markup of messages.
std::vector< Ptr< Message > > sendMediaGroup(const std::variant< std::int64_t, std::string > &chatId, const std::vector< Ptr< InputMedia >> &media, std::int32_t messageThreadId=0, bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false) const
Use this method to send a group of photos, videos, documents or audios as an album....
Ptr< ChatMember > getChatMember(const std::variant< std::int64_t, std::string > &chatId, std::int64_t userId) const
Use this method to get information about a member of a chat. The method is only guaranteed to work fo...
Ptr< Message > editMessageLiveLocation(float latitude, float longitude, const std::variant< std::int64_t, std::string > &chatId=0, std::int32_t messageId=0, const std::string &inlineMessageId="", float horizontalAccuracy=0.0f, std::int32_t heading=0, std::int32_t proximityAlertRadius=0, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to edit live location messages. A location can be edited until its livePeriod expires...
Ptr< Message > sendVoice(const std::variant< std::int64_t, std::string > &chatId, const std::variant< cpr::File, std::string > &voice, std::int32_t messageThreadId=0, const std::string &caption="", const std::string &parseMode="", const std::vector< Ptr< MessageEntity >> &captionEntities=std::vector< Ptr< MessageEntity >>(), std::int32_t duration=0, bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send audio files, if you want Telegram clients to display the file as a playable v...
bool deleteWebhook(bool dropPendingUpdates=false) const
Use this method to remove webhook integration if you decide to switch back to getUpdates.
Ptr< Message > forwardMessage(const std::variant< std::int64_t, std::string > &chatId, const std::variant< std::int64_t, std::string > &fromChatId, std::int32_t messageId, std::int32_t messageThreadId=0, bool disableNotification=false, bool protectContent=false) const
Use this method to forward messages of any kind. Service messages can't be forwarded.
bool setPassportDataErrors(std::int64_t userId, const std::vector< Ptr< PassportElementError >> &errors) const
Informs a user that some of the Telegram Passport elements they provided contains errors....
bool unpinChatMessage(const std::variant< std::int64_t, std::string > &chatId, std::int32_t messageId=0) const
Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a ...
bool unpinAllChatMessages(const std::variant< std::int64_t, std::string > &chatId) const
Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat,...
bool banChatSenderChat(const std::variant< std::int64_t, std::string > &chatId, std::int64_t senderChatId) const
Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned,...
bool setStickerSetThumbnail(const std::string &name, const std::string &title, const std::optional< std::variant< cpr::File, std::string >> &thumbnail=std::nullopt) const
Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail fi...
Ptr< Message > sendPoll(const std::variant< std::int64_t, std::string > &chatId, const std::string &question, const std::vector< std::string > &options, bool isAnonymous=true, const std::string &type="regular", bool allowsMultipleAnswers=false, std::int32_t correctOptionId=-1, const std::string &explanation="", const std::string &explanationParseMode="", const std::vector< Ptr< MessageEntity >> &explanationEntities=std::vector< Ptr< MessageEntity >>(), std::int32_t openPeriod=0, std::int32_t closeDate=0, bool isClosed=false, std::int32_t messageThreadId=0, bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send a native poll.
bool unhideGeneralForumTopic(const std::variant< std::int64_t, std::string > &chatId) const
Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administ...
Ptr< Message > sendAnimation(const std::variant< std::int64_t, std::string > &chatId, const std::variant< cpr::File, std::string > &animation, std::int32_t messageThreadId=0, std::int32_t duration=0, std::int32_t width=0, std::int32_t height=0, const std::optional< std::variant< cpr::File, std::string >> &thumbnail=std::nullopt, const std::string &caption="", const std::string &parseMode="", const std::vector< Ptr< MessageEntity >> &captionEntities=std::vector< Ptr< MessageEntity >>(), bool hasSpoiler=false, bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound)....
bool deleteStickerFromSet(const std::string &sticker) const
Use this method to delete a sticker from a set created by the bot.
bool setChatStickerSet(const std::variant< std::int64_t, std::string > &chatId, const std::string &stickerSetName) const
Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in ...
bool unpinAllForumTopicMessages(const std::variant< std::int64_t, std::string > &chatId, std::int32_t messageThreadId) const
Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrat...
std::vector< Ptr< GameHighScore > > getGameHighScores(std::int64_t userId, std::int64_t chatId=0, std::int32_t messageId=0, const std::string &inlineMessageId="") const
Use this method to get data for high score tables.
std::string exportChatInviteLink(const std::variant< std::int64_t, std::string > &chatId) const
Use this method to generate a new primary invite link for a chat; any previously generated primary li...
bool setStickerSetTitle(const std::string &name, const std::string &title) const
Use this method to set the title of a created sticker set.
Ptr< Message > stopMessageLiveLocation(const std::variant< std::int64_t, std::string > &chatId=0, std::int32_t messageId=0, const std::string &inlineMessageId="", const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to stop updating a live location message before livePeriod expires.
Ptr< File > uploadStickerFile(std::int64_t userId, const cpr::File &sticker, const std::string &stickerFormat) const
Use this method to upload a file with a sticker for later use in the createNewStickerSet and addStick...
Ptr< Message > sendVideo(const std::variant< std::int64_t, std::string > &chatId, const std::variant< cpr::File, std::string > &video, std::int32_t messageThreadId=0, std::int32_t duration=0, std::int32_t width=0, std::int32_t height=0, const std::optional< std::variant< cpr::File, std::string >> &thumbnail=std::nullopt, const std::string &caption="", const std::string &parseMode="", const std::vector< Ptr< MessageEntity >> &captionEntities=std::vector< Ptr< MessageEntity >>(), bool hasSpoiler=false, bool supportsStreaming=false, bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent...
bool setCustomEmojiStickerSetThumbnail(const std::string &name, const std::optional< std::string > &customEmojiId=std::nullopt) const
Use this method to set the thumbnail of a custom emoji sticker set.
bool editGeneralForumTopic(const std::variant< std::int64_t, std::string > &chatId, const std::string &name) const
Use this method to edit the name of the 'General' topic in a forum supergroup chat....
bool createNewStickerSet(std::int64_t userId, const std::string &name, const std::string &title, const std::vector< Ptr< InputSticker >> &stickers, const std::string &stickerFormat, const std::string &stickerType="regular", bool needsRepainting=false) const
Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker...
Ptr< UserProfilePhotos > getUserProfilePhotos(std::int64_t userId, std::int32_t offset=0, std::int32_t limit=100) const
Use this method to get a list of profile pictures for a user.
Ptr< Message > sendInvoice(const std::variant< std::int64_t, std::string > &chatId, const std::string &title, const std::string &description, const std::string &payload, const std::string &providerToken, const std::string &currency, const std::vector< Ptr< LabeledPrice >> &prices, std::int32_t messageThreadId=0, std::int32_t maxTipAmount=0, const std::vector< std::int32_t > &suggestedTipAmounts=std::vector< std::int32_t >(), const std::string &startParameter="", const std::string &providerData="", const std::string &photoUrl="", std::int32_t photoSize=0, std::int32_t photoWidth=0, std::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, bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send invoices.
bool deleteMyCommands(const Ptr< BotCommandScope > &scope=nullptr, const std::string &languageCode="") const
Use this method to delete the list of the bot's commands for the given scope and user language....
bool editForumTopic(const std::variant< std::int64_t, std::string > &chatId, std::int32_t messageThreadId, const std::string &name, const std::optional< std::string > &iconCustomEmojiId=std::nullopt) const
Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an admin...
bool answerCallbackQuery(const std::string &callbackQueryId, const std::string &text="", bool showAlert=false, const std::string &url="", std::int32_t cacheTime=0) const
Use this method to send answers to callback queries sent from inline keyboards. The answer will be di...
bool closeForumTopic(const std::variant< std::int64_t, std::string > &chatId, std::int32_t messageThreadId) const
Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator i...
cpr::Timeout getLongPollTimeout() const noexcept
Get long polling timeout.
bool setMyDescription(const std::string &description="", const std::string &languageCode="") const
Use this method to change the bot's description, which is shown in the chat with the bot if the chat ...
std::vector< Ptr< Sticker > > getCustomEmojiStickers(const std::vector< std::string > &customEmojiIds) const
Use this method to get information about custom emoji stickers by their identifiers.
std::vector< Ptr< Update > > getUpdates(std::int32_t offset, std::int32_t limit=100) const
Use this method to receive incoming updates using long polling.
bool unpinAllGeneralForumTopicMessages(const std::variant< std::int64_t, std::string > &chatId) const
Use this method to clear the list of pinned messages in a General forum topic. The bot must be an adm...
bool hideGeneralForumTopic(const std::variant< std::int64_t, std::string > &chatId) const
Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administra...
Ptr< Message > sendVideoNote(const std::variant< std::int64_t, std::string > &chatId, const std::variant< cpr::File, std::string > &videoNote, std::int32_t messageThreadId=0, std::int32_t duration=0, std::int32_t length=0, const std::optional< std::variant< cpr::File, std::string >> &thumbnail=std::nullopt, bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long....
Ptr< ForumTopic > createForumTopic(const std::variant< std::int64_t, std::string > &chatId, const std::string &name, std::int32_t iconColor=0x000000, const std::string &iconCustomEmojiId="") const
Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the...
Ptr< Message > sendGame(const std::variant< std::int64_t, std::string > &chatId, const std::string &gameShortName, std::int32_t messageThreadId=0, bool disableNotification=false, bool protectContent=false, const Ptr< ReplyParameters > &replyParameters=nullptr, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send a game.
Ptr< BotShortDescription > getMyShortDescription(const std::string &languageCode="") const
Use this method to get the current bot short description for the given user language.
bool deleteChatStickerSet(const std::variant< std::int64_t, std::string > &chatId) const
Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in ...
cpr::Timeout getUploadFilesTimeout() const noexcept
Get Api file uploads timeout.
Ptr< Message > sendVenue(const std::variant< std::int64_t, std::string > &chatId, float latitude, float longitude, const std::string &title, const std::string &address, std::int32_t messageThreadId=0, const std::string &foursquareId="", const std::string &foursquareType="", const std::string &googlePlaceId="", const std::string &googlePlaceType="", bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send information about a venue.
bool leaveChat(const std::variant< std::int64_t, std::string > &chatId) const
Use this method for your bot to leave a group, supergroup or channel.
bool setMyDefaultAdministratorRights(const Ptr< ChatAdministratorRights > &rights=nullptr, bool forChannels=false) const
Use this method to change the default administrator rights requested by the bot when it's added as an...
bool deleteMessage(const std::variant< std::int64_t, std::string > &chatId, std::int32_t messageId) const
Use this method to delete a message, including service messages, with the following limitations:
bool deleteForumTopic(const std::variant< std::int64_t, std::string > &chatId, std::int32_t messageThreadId) const
Use this method to delete a forum topic along with all its messages in a forum supergroup chat....
Ptr< ChatInviteLink > revokeChatInviteLink(const std::variant< std::int64_t, std::string > &chatId, const std::string &inviteLink) const
Use this method to revoke an invite link created by the bot. If the primary link is revoked,...
bool setStickerKeywords(const std::string &sticker, const std::vector< std::string > &keywords=std::vector< std::string >()) const
Use this method to change search keywords assigned to a regular or custom emoji sticker....
bool answerPreCheckoutQuery(const std::string &preCheckoutQueryId, bool ok, const std::string &errorMessage="") const
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmat...
Ptr< Message > sendLocation(const std::variant< std::int64_t, std::string > &chatId, float latitude, float longitude, std::int32_t messageThreadId=0, float horizontalAccuracy=0.0f, std::int32_t livePeriod=0, std::int32_t heading=0, std::int32_t proximityAlertRadius=0, bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send point on the map.
bool setMyCommands(const std::vector< Ptr< BotCommand >> &commands, const Ptr< BotCommandScope > &scope=nullptr, const std::string &languageCode="") const
Use this method to change the list of the bot's commands. See this manual for more details about bot ...
Ptr< Message > editMessageText(const std::string &text, const std::variant< std::int64_t, std::string > &chatId=0, std::int32_t messageId=0, const std::string &inlineMessageId="", const std::string &parseMode="", const std::vector< Ptr< MessageEntity >> &entities=std::vector< Ptr< MessageEntity >>(), bool disableWebPagePreview=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to edit text and game messages.
std::string downloadFile(const std::string &filePath, const std::function< bool(cpr::cpr_off_t downloadTotal, cpr::cpr_off_t downloadNow)> &progressCallback=nullptr) const
Use this method to download a file from Telegram and save it in memory. For the moment,...
Ptr< ChatAdministratorRights > getMyDefaultAdministratorRights(bool forChannels=false) const
Use this method to get the current default administrator rights of the bot.
bool setChatAdministratorCustomTitle(const std::variant< std::int64_t, std::string > &chatId, std::int64_t userId, const std::string &customTitle) const
Use this method to set a custom title for an administrator in a supergroup promoted by the bot.
void setLongPollTimeout(const cpr::Timeout &longPollTimeout)
Set long polling timeout.
void setConnectTimeout(const cpr::ConnectTimeout &timeout) noexcept
Set Api requests connection timeout.
bool setStickerEmojiList(const std::string &sticker, const std::vector< std::string > &emojiList) const
Use this method to change the list of emoji assigned to a regular or custom emoji sticker....
bool promoteChatMember(const std::variant< std::int64_t, std::string > &chatId, std::int64_t userId, bool isAnonymous=false, bool canManageChat=false, bool canDeleteMessages=false, bool canManageVideoChats=false, bool canRestrictMembers=false, bool canPromoteMembers=false, bool canChangeInfo=false, bool canInviteUsers=false, bool canPostMessages=false, bool canEditMessages=false, bool canPinMessages=false, bool canPostStories=false, bool canEditStories=false, bool canDeleteStories=false, bool canManageTopics=false) const
Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administ...
bool unbanChatMember(const std::variant< std::int64_t, std::string > &chatId, std::int64_t userId, bool onlyIfBanned=false) const
Use this method to unban a previously banned user in a supergroup or channel. The user will not retur...
bool declineChatJoinRequest(const std::variant< std::int64_t, std::string > &chatId, std::int64_t userId) const
Use this method to decline a chat join request. The bot must be an administrator in the chat for this...
void setUrl(const std::string &url) noexcept
Set Api URL.
Ptr< WebhookInfo > getWebhookInfo() const
Use this method to get current webhook status. Requires no parameters. On success,...
Ptr< Message > sendMessage(const std::variant< std::int64_t, std::string > &chatId, const std::string &text, std::int32_t messageThreadId=0, const std::string &parseMode="", const std::vector< Ptr< MessageEntity >> &entities=std::vector< Ptr< MessageEntity >>(), bool disableWebPagePreview=false, bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send text messages. On success, the sent Message is returned.
bool addStickerToSet(std::int64_t userId, const std::string &name, const Ptr< InputSticker > &sticker) const
Use this method to add a new sticker to a set created by the bot. The format of the added sticker mus...
bool setStickerMaskPosition(const std::string &sticker, const Ptr< MaskPosition > &maskPosition=nullptr) const
Use this method to change the mask position of a mask sticker. The sticker must belong to a sticker s...
Ptr< Message > sendSticker(const std::variant< std::int64_t, std::string > &chatId, const std::variant< cpr::File, std::string > &sticker, std::int32_t messageThreadId=0, const std::string &emoji="", bool disableNotification=false, bool protectContent=false, const Ptr< ReplyParameters > &replyParameters=nullptr, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success,...
bool banChatMember(const std::variant< std::int64_t, std::string > &chatId, std::int64_t userId, std::time_t untilDate=0, bool revokeMessages=false) const
Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and c...
bool setMyShortDescription(const std::string &shortDescription="", const std::string &languageCode="") const
Use this method to change the bot's short description, which is shown on the bot's profile page and i...
bool approveChatJoinRequest(const std::variant< std::int64_t, std::string > &chatId, std::int64_t userId) const
Use this method to approve a chat join request. The bot must be an administrator in the chat for this...
std::vector< Ptr< Sticker > > getForumTopicIconStickers() const
Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user....
const std::vector< std::string > & getAllowedUpdates() const noexcept
Get list of the update types you want your bot to receive.
Ptr< StickerSet > getStickerSet(const std::string &name) const
Use this method to get a sticker set. On success, a StickerSet object is returned.
Ptr< Chat > getChat(const std::variant< std::int64_t, std::string > &chatId) const
Use this method to get up to date information about the chat (current name of the user for one-on-one...
Ptr< Message > editMessageMedia(const Ptr< InputMedia > &media, const std::variant< std::int64_t, std::string > &chatId=0, std::int32_t messageId=0, const std::string &inlineMessageId="", const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to edit animation, audio, document, photo, or video messages. If a message is part of...
bool closeGeneralForumTopic(const std::variant< std::int64_t, std::string > &chatId) const
Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an admin...
Ptr< Message > editMessageCaption(const std::variant< std::int64_t, std::string > &chatId=0, std::int32_t messageId=0, const std::string &inlineMessageId="", const std::string &caption="", const std::string &parseMode="", const std::vector< Ptr< MessageEntity >> &captionEntities=std::vector< Ptr< MessageEntity >>(), const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to edit captions of messages.
bool close() const
Use this method to close the bot instance before moving it from one local server to another....
bool setMyName(const std::string &name="", const std::string &languageCode="") const
Use this method to change the bot's name.
bool answerShippingQuery(const std::string &shippingQueryId, bool ok, const std::vector< Ptr< ShippingOption >> &shippingOptions=std::vector< Ptr< ShippingOption >>(), const std::string &errorMessage="") const
If you sent an invoice requesting a shipping address and the parameter isFlexible was specified,...
bool reopenForumTopic(const std::variant< std::int64_t, std::string > &chatId, std::int32_t messageThreadId) const
Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator...
bool setWebhook(const std::string &url, const std::optional< cpr::File > &certificate=std::nullopt, const std::string &ipAddress="", std::int32_t maxConnections=40, const std::vector< std::string > &allowedUpdates=std::vector< std::string >(), bool dropPendingUpdates=false, const std::string &secretToken="") const
Use this method to specify a URL and receive incoming updates via an outgoing webhook....
Ptr< Message > sendPhoto(const std::variant< std::int64_t, std::string > &chatId, const std::variant< cpr::File, std::string > &photo, std::int32_t messageThreadId=0, const std::string &caption="", const std::string &parseMode="", const std::vector< Ptr< MessageEntity >> &captionEntities=std::vector< Ptr< MessageEntity >>(), bool disableNotification=false, bool protectContent=false, std::int32_t replyToMessageId=0, bool allowSendingWithoutReply=false, const Ptr< IReplyMarkup > &replyMarkup=nullptr) const
Use this method to send photos.
cpr::ConnectTimeout getConnectTimeout() const noexcept
Get Api requests connection timeout.
bool deleteChatPhoto(const std::variant< std::int64_t, std::string > &chatId) const
Use this method to delete a chat photo. Photos can't be changed for private chats....
bool restrictChatMember(const std::variant< std::int64_t, std::string > &chatId, std::int64_t userId, const Ptr< ChatPermissions > &permissions, bool useIndependentChatPermissions=false, std::time_t untilDate=0) const
Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergrou...
Ptr< ChatInviteLink > createChatInviteLink(const std::variant< std::int64_t, std::string > &chatId, const std::string &name="", std::time_t expireDate=0, std::int32_t memberLimit=0, bool createsJoinRequest=false) const
Use this method to create an additional invite link for a chat. The bot must be an administrator in t...
const std::string & getUrl() const noexcept
Get Api URL.
Definition: Api.hpp:14
std::shared_ptr< T > Ptr
Definition: Ptr.hpp:6
This object represents a bot command. https://core.telegram.org/bots/api#botcommand.
Definition: BotCommand.hpp:8
Base class of all bot commands scopes This object represents the scope to which bot commands are appl...
This object represents the bot's description. https://core.telegram.org/bots/api#botdescription.
This object represents the bot's name. https://core.telegram.org/bots/api#botname.
Definition: BotName.hpp:7
This object represents the bot's short description. https://core.telegram.org/bots/api#botshortdescri...
Represents the rights of an administrator in a chat. https://core.telegram.org/bots/api#chatadministr...
This object represents a chat. https://core.telegram.org/bots/api#chat.
Definition: Chat.hpp:12
The base class of all chat members objects. This object contains information about one member of a ch...
Definition: ChatMember.hpp:15
Describes actions that a non-administrator user is allowed to take in a chat. https://core....
This object represents a file ready to be downloaded.
Definition: File.hpp:13
This object represents a forum topic. https://core.telegram.org/bots/api#forumtopic.
Definition: ForumTopic.hpp:7
This object represents one row of the high scores table for a game. https://core.telegram....
The interface of reply markup objects InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove ...
Definition: IReplyMarkup.hpp:7
Base class of all inline query results This object represents one result of an inline query....
This object represents a button to be shown above inline query results. You must use exactly one of t...
This object represents the content of a media message to be sent. It should be one of:
Definition: InputMedia.hpp:13
This object describes a sticker to be added to a sticker set. https://core.telegram....
This object represents a portion of the price for goods or services. https://core....
Definition: LabeledPrice.hpp:7
This object describes the position on faces where a mask should be placed by default....
Definition: MaskPosition.hpp:7
This object describes the bot's menu button in a private chat. It should be one of:
Definition: MenuButton.hpp:14
This object represents one special entity in a text message. For example, hashtags,...
This object represents a message. https://core.telegram.org/bots/api#message.
Definition: Message.hpp:48
This object represents a unique message identifier. https://core.telegram.org/bots/api#messageid.
Definition: MessageId.hpp:7
This object represents an error in the Telegram Passport element which was submitted that should be r...
This object contains information about a poll. https://core.telegram.org/bots/api#poll.
Definition: Poll.hpp:9
This object describes the type of a reaction. Currently, it can be one of:
Definition: ReactionType.hpp:9
Describes reply parameters for the message that is being sent. https://core.telegram....
Describes an inline message sent by a Web App on behalf of a user. https://core.telegram....
This object represents one shipping option. https://core.telegram.org/bots/api#shippingoption.
This object represents a sticker. https://core.telegram.org/bots/api#sticker.
Definition: Sticker.hpp:10
This object represents a sticker set. https://core.telegram.org/bots/api#stickerset.
Definition: StickerSet.hpp:9
This object represents an incoming update. At most one of the optional parameters can be present in a...
Definition: Update.hpp:22
This object represents a Telegram user or bot. https://core.telegram.org/bots/api#user.
Definition: User.hpp:7
This object represent a user's profile pictures. https://core.telegram.org/bots/api#userprofilephotos...
Describes the current status of a webhook. https://core.telegram.org/bots/api#webhookinfo.
Definition: WebhookInfo.hpp:7