23 #ifndef TGBOT_CPP_API_H 24 #define TGBOT_CPP_API_H 29 #include <boost/property_tree/ptree.hpp> 60 typedef std::shared_ptr<std::vector<std::string>> StringArrayPtr;
65 Api(
const std::string& token);
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;
109 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
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;
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;
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;
173 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
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;
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;
235 bool answerShippingQuery(
const std::string& shippingQueryId,
bool ok,
const std::vector<ShippingOption::Ptr>& shippingOptions = std::vector<ShippingOption::Ptr>(),
const std::string& errorMessage =
"")
const;
248 bool answerPreCheckoutQuery(
const std::string& preCheckoutQueryId,
bool ok,
const std::string& errorMessage =
"")
const;
260 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
bool disableNotification =
false)
const;
272 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
bool disableNotification =
false)
const;
300 bool createNewStickerSet(int32_t userId,
const std::string& name,
const std::string& title,
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;
327 bool addStickerToSet(int32_t userId,
const std::string& name,
const std::string& title,
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;
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;
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;
419 Message::Ptr sendVideoNote(int64_t chatId,
const std::string& videoNote, int64_t replyToMessageId = 0,
bool disableNotification =
false,
430 std::vector<Message::Ptr>
sendMediaGroup(int64_t chatId,
const std::vector<InputMedia::Ptr>& media,
431 bool disableNotification =
false, int32_t replyToMessageId = 0)
const;
446 const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
const std::string& parseMode =
"",
bool disableNotification =
false)
const;
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;
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;
487 int32_t replyToMessageId = 0,
const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>(),
bool disableNotification =
false)
const;
500 int32_t inlineMessageId = 0,
const InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>())
const;
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;
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;
553 void sendChatAction(int64_t chatId,
const std::string& action)
const;
632 bool answerCallbackQuery(
const std::string & callbackQueryId,
const std::string & text=
"",
bool showAlert=
false,
const std::string &url=
"", int32_t cacheTime=0)
const;
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;
658 const std::string& inlineMessageId =
"",
const GenericReply::Ptr replyMarkup = std::make_shared<GenericReply>())
const;
690 std::vector<Update::Ptr>
getUpdates(int32_t offset = 0, int32_t limit = 100, int32_t timeout = 0,
const StringArrayPtr &allowedUpdates =
nullptr)
const;
702 void setWebhook(
const std::string& url =
"",
const InputFile::Ptr certificate =
nullptr, int32_t maxConnection = 40,
const StringArrayPtr &allowedUpdates =
nullptr)
const;
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;
745 bool kickChatMember(int64_t chatId, int32_t userId, uint64_t untilDate = 0)
const;
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;
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;
823 bool setChatTitle(int64_t chatId,
const std::string& title)
const;
840 bool pinChatMessage(int64_t chatId, int32_t messageId,
bool disableNotification =
false)
const;
864 int64_t chatId = 0, int32_t messageId = 0,
const std::string& inlineMessageId =
"")
const;
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;
887 std::string
downloadFile(
const std::string& filePath,
const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>())
const;
890 boost::property_tree::ptree sendRequest(
const std::string& method,
const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>())
const;
892 const std::string _token;
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
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
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)...
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...
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
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 ¤cy, 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
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.
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
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.
void sendChatAction(int64_t chatId, const std::string &action) const
Use this method when you need to tell the user that something is happening on the bot's side...
std::shared_ptr< Chat > Ptr
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
User::Ptr getMe() const
A simple method for testing your bot'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
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
bool leaveChat(int64_t chatId) const
Use this method for your bot to leave a group, supergroup or channel.