tgbot-cpp
|
This class executes telegram api methods. Telegram docs: https://core.telegram.org/bots/api#available-methods More...
#include <Api.h>
Public Member Functions | |
Api (const std::string &token) | |
User::Ptr | getMe () const |
A simple method for testing your bot's auth token. More... | |
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. More... | |
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. More... | |
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. More... | |
Message::Ptr | sendPhoto (int64_t chatId, const std::string &photoId, 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. More... | |
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 voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Document). More... | |
Message::Ptr | sendAudio (int64_t chatId, const std::string &audioId, 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 voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Document). More... | |
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. More... | |
Message::Ptr | sendDocument (int64_t chatId, const std::string &documentId, 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. More... | |
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. More... | |
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. More... | |
bool | answerPreCheckoutQuery (const std::string &preCheckoutQueryId, bool ok, const std::string &errorMessage="") const |
Use this method to respond to such pre-checkout queries. More... | |
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. More... | |
Message::Ptr | sendSticker (int64_t chatId, const std::string &stickerId, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=std::make_shared< GenericReply >(), bool disableNotification=false) const |
Use this method to send .webp stickers. More... | |
StickerSet::Ptr | getStickerSet (const std::string &name) const |
Use this method to get a sticker set. More... | |
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 addStickerToSet methods (can be used multiple times). More... | |
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 sticker set. More... | |
bool | createNewStickerSet (int32_t userId, const std::string &name, const std::string &title, const std::string &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 sticker set. More... | |
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. More... | |
bool | addStickerToSet (int32_t userId, const std::string &name, const std::string &title, const std::string &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. More... | |
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. More... | |
bool | deleteStickerPositionInSet (const std::string &sticker) const |
Use this method to delete a sticker from a set created by the bot. More... | |
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 as Document). More... | |
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="", 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 as Document). More... | |
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. More... | |
Message::Ptr | sendVideoNote (int64_t chatId, const std::string &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. More... | |
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. More... | |
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 voice message. More... | |
Message::Ptr | sendVoice (int64_t chatId, const std::string &voiceId, 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 voice message. More... | |
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. More... | |
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. More... | |
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). More... | |
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). More... | |
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. More... | |
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. More... | |
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. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). More... | |
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. More... | |
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, bots can download files of up to 20MB in size. More... | |
bool | leaveChat (int64_t chatId) const |
Use this method for your bot to leave a group, supergroup or channel. More... | |
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 conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. More... | |
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 objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned. More... | |
int32_t | getChatMembersCount (int64_t chatId) const |
Use this method to get the number of members in a chat. Returns Int on success. More... | |
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. More... | |
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. More... | |
bool | deleteChatStickerSet (int64_t chatId) const |
Use this method to get information about a member of a chat. Returns a ChatMember object on success. More... | |
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 displayed to the user as a notification at the top of the chat screen or as an alert. More... | |
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) More... | |
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). More... | |
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 bots). More... | |
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). More... | |
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. More... | |
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. More... | |
bool | deleteWebhook () const |
Use this method to remove webhook integration if you decide to switch back to getUpdates. More... | |
WebhookInfo::Ptr | getWebhookInfo () const |
Use this method to get current webhook status. More... | |
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. More... | |
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. More... | |
bool | unbanChatMember (int64_t chatId, int32_t userId) const |
Use this method to unban a previously kicked user in a supergroup. More... | |
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. More... | |
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. More... | |
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. More... | |
bool | setChatPhoto (int64_t chatId, const InputFile::Ptr photo) const |
Use this method to set a new profile photo for the chat. More... | |
bool | deleteChatPhoto (int64_t chatId) const |
Use this method to delete a chat photo. More... | |
bool | setChatTitle (int64_t chatId, const std::string &title) const |
Use this method to change the title of a chat. More... | |
bool | setChatDescription (int64_t chatId, const std::string &description) const |
Use this method to change the description of a supergroup or a channel. More... | |
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. More... | |
bool | unpinChatMessage (int64_t chatId) const |
Use this method to unpin a message in a supergroup or a channel. More... | |
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. More... | |
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. More... | |
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. More... | |
Friends | |
class | Bot |
This class executes telegram api methods. Telegram docs: https://core.telegram.org/bots/api#available-methods
TgBot::Api::Api | ( | const std::string & | token | ) |
bool TgBot::Api::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.
userId | User identifier of created sticker set owner. |
name | Sticker set name. |
title | Sticker set title, 1-64 characters. |
pngSticker | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. |
emojis | One or more emoji corresponding to the sticker. |
maskPosition | Optional. A JSON-serialized object for position where the mask should be placed on faces. |
bool TgBot::Api::addStickerToSet | ( | int32_t | userId, |
const std::string & | name, | ||
const std::string & | title, | ||
const std::string & | 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.
userId | User identifier of created sticker set owner. |
name | Sticker set name. |
title | Sticker set title, 1-64 characters. |
pngSticker | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet. |
emojis | One or more emoji corresponding to the sticker. |
maskPosition | Optional. A JSON-serialized object for position where the mask should be placed on faces. |
bool TgBot::Api::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 displayed to the user as a notification at the top of the chat screen or as an alert.
callbackQueryId | Unique identifier for the query to be answered |
text | Optional Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters |
showAlert | Optional If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. |
url | Optional URL that will be opened by the user's client. If you have created a Game and accepted the conditions via , specify the URL that opens your game – note that this will only work if the query comes from a callback_game button |
cacheTime | Optional The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0. |
bool TgBot::Api::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.
inlineQueryId | Unique identifier for the answered query. |
results | Array of results for the inline query. |
cacheTime | The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300. |
isPersonal | Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query. |
nextOffset | Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes. |
switchPmText | If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter |
switchPmParameter | Parameter for the start message sent to the bot when user presses the switch button |
bool TgBot::Api::answerPreCheckoutQuery | ( | const std::string & | preCheckoutQueryId, |
bool | ok, | ||
const std::string & | errorMessage = "" |
||
) | const |
Use this method to respond to such pre-checkout queries.
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field preCheckoutQuery. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
preCheckoutQueryId | Unique identifier for the query to be answered |
ok | Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. |
errorMessage | Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user. |
bool TgBot::Api::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.
If you sent an invoice requesting a shipping address and the parameter isFlexible was specified, the Bot API will send an Update with a shipping_query field to the bot.
shippingQueryId | Unique identifier for the query to be answered. |
ok | Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) |
shippingOptions | Optional. Required if ok is True. A JSON-serialized array of available shipping options. |
errorMessage | Optional. Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user. |
bool TgBot::Api::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 sticker set.
userId | User identifier of created sticker set owner. |
name | Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters. |
title | Sticker set title, 1-64 characters. |
pngSticker | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. |
emojis | One or more emoji corresponding to the sticker. |
containsMasks | Optional. Pass True, if a set of mask stickers should be created. |
maskPosition | Optional. A JSON-serialized object for position where the mask should be placed on faces. |
bool TgBot::Api::createNewStickerSet | ( | int32_t | userId, |
const std::string & | name, | ||
const std::string & | title, | ||
const std::string & | 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 sticker set.
userId | User identifier of created sticker set owner. |
name | Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters. |
title | Sticker set title, 1-64 characters. |
pngSticker | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet. |
emojis | One or more emoji corresponding to the sticker. |
containsMasks | Optional. Pass True, if a set of mask stickers should be created. |
maskPosition | Optional. A JSON-serialized object for position where the mask should be placed on faces. |
bool TgBot::Api::deleteChatPhoto | ( | int64_t | chatId | ) | const |
Use this method to delete a chat photo.
Photos can't be changed for private chats.
chatId | Unique identifier for the target chat. |
bool TgBot::Api::deleteChatStickerSet | ( | int64_t | chatId | ) | const |
Use this method to get information about a member of a chat. Returns a ChatMember object on success.
chatId | Unique identifier for the target chat of the target supergroup or channel. |
void TgBot::Api::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).
chatId | Unique identifier for the target chat. |
messageId | Unique identifier for the target message. |
bool TgBot::Api::deleteStickerPositionInSet | ( | const std::string & | sticker | ) | const |
Use this method to delete a sticker from a set created by the bot.
stickers | File identifier of the sticker. |
bool TgBot::Api::deleteWebhook | ( | ) | const |
Use this method to remove webhook integration if you decide to switch back to getUpdates.
Requires no parameters.
std::string TgBot::Api::downloadFile | ( | const std::string & | filePath, |
const std::vector< HttpReqArg > & | args = std::vector< HttpReqArg >() |
||
) | const |
Downloads file from Telegram and saves it in memory.
filePath | Telegram file path. |
args | Additional api parameters. |
Message::Ptr TgBot::Api::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).
chatId | Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel. |
messageId | Optional Required if inline_message_id is not specified. Identifier of the sent message |
caption | Optional New caption of the message |
inlineMessageId | Optional Required if chat_id and message_id are not specified. Identifier of the inline message |
replyMarkup | Optional A JSON-serialized object for an inline keyboard. |
Message::Ptr TgBot::Api::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).
latitude | Latitude of new location. |
longitude | Longitude of new location. |
chatId | Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel. |
messageId | Optional. Required if inlineMessageId is not specified. Identifier of the sent message. |
inlineMessageId | Optional. Required if chatId and messageId are not specified. Identifier of the inline message. |
replyMarkup | Optional. A JSON-serialized object for a new inline keyboard. |
Message::Ptr TgBot::Api::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 bots).
chatId | Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel. |
messageId | Optional Required if inline_message_id is not specified. Identifier of the sent message |
inlineMessageId | Optional Required if chat_id and message_id are not specified. Identifier of the inline message |
replyMarkup | Optional A JSON-serialized object for an inline keyboard. |
Message::Ptr TgBot::Api::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)
text | New text of the message |
chatId | Optional Required if inline_message_id is not specified. Unique identifier for the target chat of the target channel. |
messageId | Optional Required if inline_message_id is not specified. Identifier of the sent message |
inlineMessageId | Optional Required if chat_id and message_id are not specified. Identifier of the inline message |
parseMode | Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
disableWebPagePreview | Optional Disables link previews for links in this message |
replyMarkup | Optional A JSON-serialized object for an inline keyboard. |
std::string TgBot::Api::exportChatInviteLink | ( | int64_t | chatId | ) | const |
Use this method to generate a new invite link for a chat; any previously generated link is revoked.
chatId | Unique identifier for the target chat. |
Message::Ptr TgBot::Api::forwardMessage | ( | int64_t | chatId, |
int64_t | fromChatId, | ||
int32_t | messageId, | ||
bool | disableNotification = false |
||
) | const |
Use this method to forward messages of any kind.
chatId | Unique identifier for the target chat. |
fromChatId | Unique identifier for the chat where the original message was sent — User or GroupChat id. |
messageId | Unique message identifier. |
disableNotification | Optional. Sends the message silenty. |
Chat::Ptr TgBot::Api::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 conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
chatId | Unique identifier for the target chat of the target supergroup or channel. |
std::vector<ChatMember::Ptr> TgBot::Api::getChatAdministrators | ( | int64_t | chatId | ) | const |
Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
chatId | Unique identifier for the target chat of the target supergroup or channel. |
ChatMember::Ptr TgBot::Api::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.
chatId | Unique identifier for the target chat of the target supergroup or channel. |
userId | Unique identifier of the target user |
int32_t TgBot::Api::getChatMembersCount | ( | int64_t | chatId | ) | const |
Use this method to get the number of members in a chat. Returns Int on success.
chatId | Unique identifier for the target chat of the target supergroup or channel. |
File::Ptr TgBot::Api::getFile | ( | const std::string & | fileId | ) | const |
std::vector<GameHighScore::Ptr> TgBot::Api::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.
Will return the score of the specified user and several of his neighbors in a game.
userId | User identifier. |
chatId | Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat |
messageId | Optional. Required if inlineMessageId is not specified. Identifier of the sent message |
inlineMessageId | Optional. Required if chatId and messageId are not specified. Identifier of the inline message |
User::Ptr TgBot::Api::getMe | ( | ) | const |
A simple method for testing your bot's auth token.
StickerSet::Ptr TgBot::Api::getStickerSet | ( | const std::string & | name | ) | const |
Use this method to get a sticker set.
chatId | Name of the sticker set. |
std::vector<Update::Ptr> TgBot::Api::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.
This method will not work if an outgoing webhook is set up. In order to avoid getting duplicate updates, recalculate offset after each server response.
offset | Optional. Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. |
limit | Optional. Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100. |
timeout | Optional. Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. |
allowed_updates | Optional. List the types of updates you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the previous setting will be used. |
UserProfilePhotos::Ptr TgBot::Api::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.
userId | Unique identifier of the target user. |
offset | Optional. Sequential number of the first photo to be returned. By default, all photos are returned. |
limit | Optional. Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100. |
WebhookInfo::Ptr TgBot::Api::getWebhookInfo | ( | ) | const |
Use this method to get current webhook status.
Requires no parameters. If the bot is using getUpdates, will return an object with the url field empty.
bool TgBot::Api::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.
chatId | Unique identifier for the target group. |
userId | Unique identifier of the target user. |
untilDate | Optional. Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. |
bool TgBot::Api::leaveChat | ( | int64_t | chatId | ) | const |
Use this method for your bot to leave a group, supergroup or channel.
chatId | Unique identifier for the target chat of the target supergroup or channel. |
bool TgBot::Api::pinChatMessage | ( | int64_t | chatId, |
int32_t | messageId, | ||
bool | disableNotification = false |
||
) | const |
Use this method to pin a message in a supergroup or a channel.
chatId | Unique identifier for the target chat. |
messageId | Identifier of a message to pin. |
disableNotification | Optional. Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels. |
bool TgBot::Api::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.
chatId | Unique identifier for the target chat of the target supergroup or channal. |
userId | Unique identifier of the target user. |
canChangeInfo | Optional. Pass True, if the administrator can change chat title, photo and other settings. |
canPostMessages | Optional. Pass True, if the administrator can create channel posts, channels only. |
canEditMessages | Optional. Pass True, if the administrator can edit messages of other users and can pin messages, channels only. |
canDeleteMessages | Optional. Pass True, if the administrator can delete messages of other users. |
canInviteUsers | Optional. Pass True, if the administrator can invite new users to the chat. |
canRestrictMembers | Optional. Pass True, if the administrator can restrict, ban or unban chat members. |
canPinMessages | Optional. Pass True, if the administrator can pin messages, supergroups only. |
canPromoteMembers | Optional. Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him). |
bool TgBot::Api::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.
chatId | Unique identifier for the target chat of the target supergroup. |
userId | Unique identifier of the target user. |
untilDate | Optional. Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever. |
canSendMessages | Optional. Pass True, if the user can send text messages, contacts, locations and venues. |
canSendMediaMessages | Optional. Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages. |
canSendOtherMessages | Optional. Pass True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages. |
canAddWebPagePreviews | Optional. Pass True, if the user may add web page previews to their messages, implies can_send_media_messages. |
Message::Ptr TgBot::Api::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 voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Document).
chatId | Unique identifier for the target chat. |
audio | Audio to send. |
caption | Audio caption, 0-200 characters |
duration | Duration of sent audio in seconds. |
performer | Performer |
title | Track name |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
parseMode | Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::sendAudio | ( | int64_t | chatId, |
const std::string & | audioId, | ||
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 voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Document).
chatId | Unique identifier for the target chat. |
audio | Id of the audio that is already on the Telegram servers. |
caption | Audio caption, 0-200 characters |
duration | Duration of sent audio in seconds. |
performer | Performer |
title | Track name |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
parseMode | Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
disableNotification | Optional. Sends the message silenty. |
void TgBot::Api::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. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot. We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
chatId | Unique identifier for the target chat. |
action | Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for location data. |
Message::Ptr TgBot::Api::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.
chatId | Unique identifier for the target chat. |
phoneNumber | Contact's phone number. |
firstName | Contact's first name. |
lastName | Contact's last name. |
disableNotification | Optional. Sends the message silenty. |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
Message::Ptr TgBot::Api::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.
chatId | Unique identifier for the target chat. |
document | Document to send. |
caption | Document caption (may also be used when resending documents by file_id), 0-200 characters |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
parseMode | Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::sendDocument | ( | int64_t | chatId, |
const std::string & | documentId, | ||
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.
chatId | Unique identifier for the target chat. |
document | Id of the document that is already on the Telegram servers. |
caption | Document caption (may also be used when resending documents by file_id), 0-200 characters |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
parseMode | Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::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.
chatId | Unique identifier for the target chat. |
gameShortName | Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather. |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. A JSON-serialized object for an inline keyboard. If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::sendInvoice | ( | int64_t | chatId, |
const std::string & | title, | ||
const std::string & | description, | ||
const std::string & | payload, | ||
const std::string & | providerToken, | ||
const std::string & | startParameter, | ||
const std::string & | currency, | ||
const std::vector< LabeledPrice::Ptr > & | prices, | ||
const std::string & | providerData = "" , |
||
const std::string & | photoUrl = "" , |
||
int32_t | photoSize = 0 , |
||
int32_t | photoWidth = 0 , |
||
int32_t | photoHeight = 0 , |
||
bool | needName = false , |
||
bool | needPhoneNumber = false , |
||
bool | needEmail = false , |
||
bool | needShippingAddress = false , |
||
bool | sendPhoneNumberToProvider = false , |
||
bool | sendEmailToProvider = false , |
||
bool | isFlexible = false , |
||
int32_t | replyToMessageId = 0 , |
||
const GenericReply::Ptr | replyMarkup = std::make_shared< GenericReply >() , |
||
bool | disableNotification = false |
||
) | const |
Use this method to send invoices.
chatId | Unique identifier for the target private chat. |
title | Product name, 1-32 characters. |
description | Product description, 1-255 characters. |
payload | Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. |
providerToken | Payments provider token, obtained via Botfather. |
startParameter | Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter. |
currency | Three-letter ISO 4217 currency code. |
prices | Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) |
providerData | Optional. JSON-encoded data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. |
photoUrl | Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for. |
photoSize | Optional. Photo size |
photoWidth | Optional. Photo width |
photoHeight | Optional. Photo height |
needName | Optional. Pass True, if you require the user's full name to complete the order. |
needPhoneNumber | Optional. Pass True, if you require the user's phone number to complete the order. |
needEmail | Optional. Pass True, if you require the user's email address to complete the order. |
needShippingAddress | Optional. Pass True, if you require the user's shipping address to complete the order. |
sendPhoneNumberToProvider | Optional. Pass True, if user's phone number should be sent to provider. |
sendEmailToProvider | Optional. Pass True, if user's email address should be sent to provider |
isFlexible | Optional. Pass True, if the final price depends on the shipping method. |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button. |
disableNotification | Optional. Sends the message silently. Users will receive a notification with no sound. |
Message::Ptr TgBot::Api::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.
chatId | Unique identifier for the target chat. |
latitude | Latitude of location. |
longitude | Longitude of location. |
livePeriod | Optional. Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400). |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
disableNotification | Optional. Sends the message silenty. |
std::vector<Message::Ptr> TgBot::Api::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.
chatId | Unique identifier for the target chat of the target channel. |
media | A JSON-serialized array describing photos and videos to be sent, must include 2–10 items. |
disableNotification | Optional. Sends the messages silently. Users will receive a notification with no sound. |
replyToMessageId | Optional. If the messages are a reply, ID of the original message. |
Message::Ptr TgBot::Api::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.
chatId | Unique identifier for the target chat. |
text | Text of the message to be sent. |
disableWebPagePreview | Optional. Disables link previews for links in this message. |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
parseMode | Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::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.
chatId | Unique identifier for the target chat. |
photo | Photo to send. |
caption | Optional. Photo caption. |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
parseMode | Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::sendPhoto | ( | int64_t | chatId, |
const std::string & | photoId, | ||
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.
chatId | Unique identifier for the target chat. |
photo | Photo to send. Id of the photo that is already on the Telegram servers. |
caption | Optional. Photo caption. |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
parseMode | Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::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.
chatId | Unique identifier for the target chat. |
sticker | Sticker to send. |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::sendSticker | ( | int64_t | chatId, |
const std::string & | stickerId, | ||
int32_t | replyToMessageId = 0 , |
||
const GenericReply::Ptr | replyMarkup = std::make_shared< GenericReply >() , |
||
bool | disableNotification = false |
||
) | const |
Use this method to send .webp stickers.
chatId | Unique identifier for the target chat. |
stickerId | Id of the sticker that is already on the Telegram servers. |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::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.
chatId | Unique identifier for the target chat. |
latitude | Latitude of location. |
longitude | Longitude of location. |
title | Name of the venue. |
address | Address of the venue. |
foursquare_id | Foursquare identifier of the venue. |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::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 as Document).
chatId | Unique identifier for the target chat. |
video | Video to send. |
supportsStreaming | Optional. Pass True, if the uploaded video is suitable for streaming. |
duration | Optional. Duration of sent video in seconds |
width | Optional. Video width |
height | Optional. Video height |
caption | Optional. Video caption (may also be used when resending videos by file_id), 0-200 characters |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
parseMode | Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::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 = "" , |
||
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 as Document).
chatId | Unique identifier for the target chat. |
videoId | Id of the video that is already on the Telegram servers. |
supportsStreaming | Optional. Pass True, if the uploaded video is suitable for streaming. |
duration | Optional. Duration of sent video in seconds |
width | Optional. Video width |
height | Optional. Video height |
caption | Optional. Video caption (may also be used when resending videos by file_id), 0-200 characters |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
parseMode | Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::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.
chatId | Unique identifier for the target chat. |
videoNote | Video note to send. |
replyToMessageId | If the message is a reply, ID of the original message. |
disableNotification | Sends the message silently. Users will receive a notification with no sound. |
duration | Duration of sent video in seconds. |
length | Video width and height. |
replyMarkup | Additional interface options. A object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. |
Message::Ptr TgBot::Api::sendVideoNote | ( | int64_t | chatId, |
const std::string & | 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.
chatId | Unique identifier for the target chat. |
videoNote | Id of the video note that exists on the Telegram servers. |
replyToMessageId | If the message is a reply, ID of the original message. |
disableNotification | Sends the message silently. Users will receive a notification with no sound. |
duration | Duration of sent video in seconds. |
length | Video width and height. |
replyMarkup | Additional interface options. A object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. |
Message::Ptr TgBot::Api::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 voice message.
chatId | Unique identifier for the target chat. |
voice | Audio file to send. |
caption | Voice message caption, 0-200 characters |
duration | Duration of send audio in seconds. |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
parseMode | Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
disableNotification | Optional. Sends the message silenty. |
Message::Ptr TgBot::Api::sendVoice | ( | int64_t | chatId, |
const std::string & | voiceId, | ||
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 voice message.
chatId | Unique identifier for the target chat. |
voiceId | Id of the voice that is already on the Telegram servers. |
caption | Voice message caption, 0-200 characters |
duration | Duration of send audio in seconds. |
replyToMessageId | Optional. If the message is a reply, ID of the original message. |
replyMarkup | Optional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. |
parseMode | Optional. Set it to "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
disableNotification | Optional. Sends the message silenty. |
bool TgBot::Api::setChatDescription | ( | int64_t | chatId, |
const std::string & | description | ||
) | const |
Use this method to change the description of a supergroup or a channel.
chatId | Unique identifier for the target chat. |
description | New chat description, 1-255 characters. |
bool TgBot::Api::setChatPhoto | ( | int64_t | chatId, |
const InputFile::Ptr | photo | ||
) | const |
Use this method to set a new profile photo for the chat.
Photos can't be changed for private chats.
chatId | Unique identifier for the target chat. |
photo | New chat photo. |
bool TgBot::Api::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.
chatId | Unique identifier for the target chat of the target supergroup or channel. |
stickerSetName | Name of the sticker set to be set as the group sticker set. |
bool TgBot::Api::setChatTitle | ( | int64_t | chatId, |
const std::string & | title | ||
) | const |
Use this method to change the title of a chat.
Titles can't be changed for private chats.
chatId | Unique identifier for the target chat. |
title | New chat title, 1-255 characters. |
Message::Ptr TgBot::Api::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.
Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
userId | User identifier. |
score | New score, must be non-negative. |
force | Optional. Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters. |
disableEditMessage | Optional. Pass True, if the game message should not be automatically edited to include the current scoreboard. |
chatId | Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat |
messageId | Optional. Required if inlineMessageId is not specified. Identifier of the sent message |
inlineMessageId | Optional. Required if chatId and messageId are not specified. Identifier of the inline message |
bool TgBot::Api::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.
stickers | File identifier of the sticker. |
position | New sticker position in the set, zero-based. |
void TgBot::Api::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.
If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. www.example.com/<token>. Since nobody else knows your bot‘s token, you can be pretty sure it’s us. You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up. We currently do not support self-signed certificates. Ports currently supported for Webhooks: 443, 80, 88, 8443.
url | Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration. |
Message::Ptr TgBot::Api::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).
chatId | Optional. Required if inlineMessageId is not specified. Unique identifier for the target chat of the target channel. |
messageId | Optional. Required if inlineMessageId is not specified. Identifier of the sent message. |
inlineMessageId | Optional. Required if chatId and messageId are not specified. Identifier of the inline message. |
replyMarkup | Optional. A JSON-serialized object for a new inline keyboard. |
bool TgBot::Api::unbanChatMember | ( | int64_t | chatId, |
int32_t | userId | ||
) | const |
Use this method to unban a previously kicked user in a supergroup.
chatId | Unique identifier for the target group. |
userId | Unique identifier of the target user. |
bool TgBot::Api::unpinChatMessage | ( | int64_t | chatId | ) | const |
Use this method to unpin a message in a supergroup or a channel.
chatId | Unique identifier for the target chat. |
File::Ptr TgBot::Api::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 addStickerToSet methods (can be used multiple times).
userId | User identifier of sticker file owner. |
pngSticker | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. |