tgbot-cpp
TgBot::Api Class Reference

#include <Api.h>

Public Member Functions

 Api (const std::string &token)
 
User::Ptr getMe () const
 
Message::Ptr sendMessage (int64_t chatId, const std::string &text, bool disableWebPagePreview=false, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr(), const std::string &parseMode="", bool disableNotification=false) const
 
Message::Ptr forwardMessage (int64_t chatId, int64_t fromChatId, int32_t messageId, bool disableNotification=false) const
 
Message::Ptr sendPhoto (int64_t chatId, const InputFile::Ptr photo, const std::string &caption="", int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr(), bool disableNotification=false) const
 
Message::Ptr sendPhoto (int64_t chatId, const std::string &photoId, const std::string &caption="", int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr(), bool disableNotification=false) const
 
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=GenericReply::Ptr(), bool disableNotification=false) const
 
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=GenericReply::Ptr(), bool disableNotification=false) const
 
Message::Ptr sendDocument (int64_t chatId, const InputFile::Ptr document, const std::string &caption="", int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr(), bool disableNotification=false) const
 
Message::Ptr sendDocument (int64_t chatId, const std::string &documentId, const std::string &caption="", int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr(), bool disableNotification=false) const
 
Message::Ptr sendSticker (int64_t chatId, const InputFile::Ptr sticker, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr(), bool disableNotification=false) const
 
Message::Ptr sendSticker (int64_t chatId, const std::string &stickerId, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr(), bool disableNotification=false) const
 
Message::Ptr sendVideo (int64_t chatId, const InputFile::Ptr video, int32_t duration=0, int32_t width=0, int32_t height=0, const std::string &caption="", int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr(), bool disableNotification=false) const
 
Message::Ptr sendVideo (int64_t chatId, const std::string &videoId, int32_t duration=0, int32_t width=0, int32_t height=0, const std::string &caption="", int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr(), bool disableNotification=false) const
 
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=GenericReply::Ptr(), bool disableNotification=false) const
 
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=GenericReply::Ptr(), bool disableNotification=false) const
 
Message::Ptr sendLocation (int64_t chatId, float latitude, float longitude, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr(), bool disableNotification=false) const
 
Message::Ptr sendVenue (int64_t chatId, float latitude, float longitude, std::string title, std::string address, std::string foursquareId="", bool disableNotification=false, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr()) const
 
Message::Ptr sendContact (int64_t chatId, std::string phoneNumber, std::string firstName, std::string lastName="", bool disableNotification=false, int32_t replyToMessageId=0, const GenericReply::Ptr replyMarkup=GenericReply::Ptr()) const
 
void sendChatAction (int64_t chatId, const std::string &action) const
 
UserProfilePhotos::Ptr getUserProfilePhotos (int32_t userId, int32_t offset=0, int32_t limit=100) const
 
File::Ptr getFile (const std::string &fileId) const
 
bool leaveChat (int64_t chatId) const
 
Chat::Ptr getChat (int64_t chatId) const
 
std::vector< ChatMember::PtrgetChatAdministrators (int64_t chatId) const
 
int32_t getChatMembersCount (int64_t chatId) const
 
ChatMember::Ptr getChatMember (int64_t chatId, int32_t userId) const
 
bool answerCallbackQuery (const std::string &callbackQueryId, const std::string &text="", bool showAlert=false, const std::string &url="", int32_t cacheTime=0) const
 
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=GenericReply::Ptr()) const
 
Message::Ptr editMessageCaption (int64_t chatId=0, int32_t messageId=0, const std::string &caption="", const std::string &inlineMessageId="", const GenericReply::Ptr replyMarkup=GenericReply::Ptr()) const
 
Message::Ptr editMessageReplyMarkup (int64_t chatId=0, int32_t messageId=0, const std::string &inlineMessageId="", const GenericReply::Ptr replyMarkup=GenericReply::Ptr()) const
 
void deleteMessage (int64_t chatId, int32_t messageId) const
 
std::vector< Update::PtrgetUpdates (int32_t offset=0, int32_t limit=100, int32_t timeout=0, const StringArrayPtr &allowedUpdates=nullptr) const
 
void setWebhook (const std::string &url="", const InputFile::Ptr certificate=nullptr, int32_t maxConnection=40, const StringArrayPtr &allowedUpdates=nullptr) const
 
bool deleteWebhook () const
 
WebhookInfo::Ptr getWebhookInfo () const
 
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
 
bool kickChatMember (int64_t chatId, int32_t userId) const
 
bool unbanChatMember (int64_t chatId, int32_t userId) const
 
std::string downloadFile (const std::string &filePath, const std::vector< HttpReqArg > &args=std::vector< HttpReqArg >()) const
 

Friends

class Bot
 

Detailed Description

This class executes telegram api methods. Telegram docs: https://core.telegram.org/bots/api#available-methods

Definition at line 52 of file Api.h.

Constructor & Destructor Documentation

◆ Api()

TgBot::Api::Api ( const std::string &  token)

Member Function Documentation

◆ answerCallbackQuery()

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.

Parameters
callbackQueryIdUnique identifier for the query to be answered
textOptional Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
showAlertOptional If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
urlOptional 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
cacheTimeOptional 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.
Returns
True on success

◆ answerInlineQuery()

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.

Parameters
inlineQueryIdUnique identifier for the answered query.
resultsArray of results for the inline query.
cacheTimeThe maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
isPersonalPass 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.
nextOffsetPass 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.
switchPmTextIf 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
switchPmParameterParameter for the start message sent to the bot when user presses the switch button
Returns
True on success

◆ deleteMessage()

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).

Parameters
chatIdUnique identifier for the target chat.
messageIdUnique identifier for the target message.

◆ deleteWebhook()

bool TgBot::Api::deleteWebhook ( ) const

Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. Requires no parameters.

◆ downloadFile()

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.

Parameters
filePathTelegram file path.
argsAdditional api parameters.
Returns
File contents in a string.

◆ editMessageCaption()

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 = GenericReply::Ptr() 
) const

Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).

Parameters
chatIdOptional Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format )
messageIdOptional Required if inline_message_id is not specified. Identifier of the sent message
captionOptional New caption of the message
inlineMessageIdOptional Required if chat_id and message_id are not specified. Identifier of the inline message
replyMarkupOptional A JSON-serialized object for an inline keyboard.
Returns
Message object on success, otherwise nullptr

◆ editMessageReplyMarkup()

Message::Ptr TgBot::Api::editMessageReplyMarkup ( int64_t  chatId = 0,
int32_t  messageId = 0,
const std::string &  inlineMessageId = "",
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr() 
) const

Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).

Parameters
chatIdOptional Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format )
messageIdOptional Required if inline_message_id is not specified. Identifier of the sent message
inlineMessageIdOptional Required if chat_id and message_id are not specified. Identifier of the inline message
replyMarkupOptional A JSON-serialized object for an inline keyboard.
Returns
Message object on success, otherwise nullptr

◆ editMessageText()

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 = GenericReply::Ptr() 
) const

Use this method to edit text and game messages sent by the bot or via the bot (for inline bots)

Parameters
textNew text of the message
chatIdOptional Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format )
messageIdOptional Required if inline_message_id is not specified. Identifier of the sent message
inlineMessageIdOptional Required if chat_id and message_id are not specified. Identifier of the inline message
parseModeOptional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
disableWebPagePreviewOptional Disables link previews for links in this message
replyMarkupOptional A JSON-serialized object for an inline keyboard.
Returns
Message object on success, otherwise nullptr

◆ forwardMessage()

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.

Parameters
chatIdUnique identifier for the target chat.
fromChatIdUnique identifier for the chat where the original message was sent — User or GroupChat id.
messageIdUnique message identifier.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ getChat()

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.

Parameters
chatIdUnique identifier for the target chat or username of the target supergroup or channel (in the format )
Returns
Chat object.

◆ getChatAdministrators()

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.

Parameters
chatIdUnique identifier for the target chat or username of the target supergroup or channel (in the format )
Returns
ChatMember object.

◆ getChatMember()

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.

Parameters
chatIdUnique identifier for the target chat or username of the target supergroup or channel (in the format )
userIdUnique identifier of the target user
Returns
ChatMember object.

◆ getChatMembersCount()

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.

Parameters
chatIdUnique identifier for the target chat or username of the target supergroup or channel (in the format )
Returns
Int.

◆ getFile()

File::Ptr TgBot::Api::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.

Parameters
fileIdFile identifier to get info about
Returns
A File object.

◆ getMe()

User::Ptr TgBot::Api::getMe ( ) const

A simple method for testing your bot's auth token.

Returns
Basic information about the bot in form of a User object.

◆ getUpdates()

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.

Parameters
offsetOptional. 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.
limitOptional. Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100.
timeoutOptional. Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling.
allowed_updatesOptional. 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.
Returns
An Array of Update objects

◆ getUserProfilePhotos()

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.

Parameters
userIdUnique identifier of the target user.
offsetOptional. Sequential number of the first photo to be returned. By default, all photos are returned.
limitOptional. Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100.
Returns
A UserProfilePhotos object.

◆ getWebhookInfo()

WebhookInfo::Ptr TgBot::Api::getWebhookInfo ( ) const

Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.

◆ kickChatMember()

bool TgBot::Api::kickChatMember ( int64_t  chatId,
int32_t  userId 
) const

Use this method to kick a user from a group or a supergroup.

Parameters
chatIdUnique identifier for the target group.
userIdUnique identifier of the target user.
Returns
True on success

◆ leaveChat()

bool TgBot::Api::leaveChat ( int64_t  chatId) const

Use this method for your bot to leave a group, supergroup or channel.

Parameters
chatIdUnique identifier for the target chat or username of the target supergroup or channel (in the format )
Returns
True on success

◆ sendAudio() [1/2]

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 = GenericReply::Ptr(),
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).

Parameters
chatIdUnique identifier for the target chat.
audioAudio to send.
captionAudio caption, 0-200 characters
durationDuration of sent audio in seconds.
performerPerformer
titleTrack name
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendAudio() [2/2]

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 = GenericReply::Ptr(),
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).

Parameters
chatIdUnique identifier for the target chat.
audioId of the audio that is already on the Telegram servers.
captionAudio caption, 0-200 characters
durationDuration of sent audio in seconds.
performerPerformer
titleTrack name
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendChatAction()

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.

Parameters
chatIdUnique identifier for the target chat.
actionType 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.

◆ sendContact()

Message::Ptr TgBot::Api::sendContact ( int64_t  chatId,
std::string  phoneNumber,
std::string  firstName,
std::string  lastName = "",
bool  disableNotification = false,
int32_t  replyToMessageId = 0,
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr() 
) const

Use this method to send phone contacts. On success, the sent Message is returned.

Parameters
chatIdUnique identifier for the target chat.
phoneNumberContact's phone number.
firstNameContact's first name.
lastNameContact's last name.
disableNotificationOptional. Sends the message silenty.
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
Returns
On success, the sent message is returned.

◆ sendDocument() [1/2]

Message::Ptr TgBot::Api::sendDocument ( int64_t  chatId,
const InputFile::Ptr  document,
const std::string &  caption = "",
int32_t  replyToMessageId = 0,
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr(),
bool  disableNotification = false 
) const

Use this method to send general files.

Parameters
chatIdUnique identifier for the target chat.
documentDocument to send.
captionDocument caption (may also be used when resending documents by file_id), 0-200 characters
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendDocument() [2/2]

Message::Ptr TgBot::Api::sendDocument ( int64_t  chatId,
const std::string &  documentId,
const std::string &  caption = "",
int32_t  replyToMessageId = 0,
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr(),
bool  disableNotification = false 
) const

Use this method to send general files.

Parameters
chatIdUnique identifier for the target chat.
documentId of the document that is already on the Telegram servers.
captionDocument caption (may also be used when resending documents by file_id), 0-200 characters
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendLocation()

Message::Ptr TgBot::Api::sendLocation ( int64_t  chatId,
float  latitude,
float  longitude,
int32_t  replyToMessageId = 0,
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr(),
bool  disableNotification = false 
) const

Use this method to send point on the map.

Parameters
chatIdUnique identifier for the target chat.
latitudeLatitude of location.
longitudeLongitude of location.
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendMessage()

Message::Ptr TgBot::Api::sendMessage ( int64_t  chatId,
const std::string &  text,
bool  disableWebPagePreview = false,
int32_t  replyToMessageId = 0,
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr(),
const std::string &  parseMode = "",
bool  disableNotification = false 
) const

Use this method to send text messages.

Parameters
chatIdUnique identifier for the target chat.
textText of the message to be sent.
disableWebPagePreviewOptional. Disables link previews for links in this message.
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
parseModeOptional. 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.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendPhoto() [1/2]

Message::Ptr TgBot::Api::sendPhoto ( int64_t  chatId,
const InputFile::Ptr  photo,
const std::string &  caption = "",
int32_t  replyToMessageId = 0,
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr(),
bool  disableNotification = false 
) const

Use this method to send photos.

Parameters
chatIdUnique identifier for the target chat.
photoPhoto to send.
captionOptional. Photo caption.
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendPhoto() [2/2]

Message::Ptr TgBot::Api::sendPhoto ( int64_t  chatId,
const std::string &  photoId,
const std::string &  caption = "",
int32_t  replyToMessageId = 0,
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr(),
bool  disableNotification = false 
) const

Use this method to send photos.

Parameters
chatIdUnique identifier for the target chat.
photoPhoto to send. Id of the photo that is already on the Telegram servers.
captionOptional. Photo caption.
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendSticker() [1/2]

Message::Ptr TgBot::Api::sendSticker ( int64_t  chatId,
const InputFile::Ptr  sticker,
int32_t  replyToMessageId = 0,
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr(),
bool  disableNotification = false 
) const

Use this method to send .webp stickers.

Parameters
chatIdUnique identifier for the target chat.
stickerSticker to send.
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendSticker() [2/2]

Message::Ptr TgBot::Api::sendSticker ( int64_t  chatId,
const std::string &  stickerId,
int32_t  replyToMessageId = 0,
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr(),
bool  disableNotification = false 
) const

Use this method to send .webp stickers.

Parameters
chatIdUnique identifier for the target chat.
stickerId of the sticker that is already on the Telegram servers.
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendVenue()

Message::Ptr TgBot::Api::sendVenue ( int64_t  chatId,
float  latitude,
float  longitude,
std::string  title,
std::string  address,
std::string  foursquareId = "",
bool  disableNotification = false,
int32_t  replyToMessageId = 0,
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr() 
) const

Use this method to send information about a venue. On success, the sent Message is returned.

Parameters
chatIdUnique identifier for the target chat.
latitudeLatitude of location.
longitudeLongitude of location.
titleName of the venue.
addressAddress of the venue.
foursquare_idFoursquare identifier of the venue.
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendVideo() [1/2]

Message::Ptr TgBot::Api::sendVideo ( int64_t  chatId,
const InputFile::Ptr  video,
int32_t  duration = 0,
int32_t  width = 0,
int32_t  height = 0,
const std::string &  caption = "",
int32_t  replyToMessageId = 0,
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr(),
bool  disableNotification = false 
) const

Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).

Parameters
chatIdUnique identifier for the target chat.
videoVideo to send.
durationDuration of sent video in seconds
widthVideo width
heightVideo height
captionVideo caption (may also be used when resending videos by file_id), 0-200 characters
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendVideo() [2/2]

Message::Ptr TgBot::Api::sendVideo ( int64_t  chatId,
const std::string &  videoId,
int32_t  duration = 0,
int32_t  width = 0,
int32_t  height = 0,
const std::string &  caption = "",
int32_t  replyToMessageId = 0,
const GenericReply::Ptr  replyMarkup = GenericReply::Ptr(),
bool  disableNotification = false 
) const

Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).

Parameters
chatIdUnique identifier for the target chat.
videoId of the video that is already on the Telegram servers.
durationDuration of sent video in seconds
widthVideo width
heightVideo height
captionVideo caption (may also be used when resending videos by file_id), 0-200 characters
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendVoice() [1/2]

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 = GenericReply::Ptr(),
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.

Parameters
chatIdUnique identifier for the target chat.
voiceAudio file to send.
captionVoice message caption, 0-200 characters
durationDuration of send audio in seconds.
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ sendVoice() [2/2]

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 = GenericReply::Ptr(),
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.

Parameters
chatIdUnique identifier for the target chat.
voiceIdId of the voice that is already on the Telegram servers.
captionVoice message caption, 0-200 characters
durationDuration of send audio in seconds.
replyToMessageIdOptional. If the message is a reply, ID of the original message.
replyMarkupOptional. Additional interface options. A object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
disableNotificationOptional. Sends the message silenty.
Returns
On success, the sent message is returned.

◆ setWebhook()

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.

Parameters
urlOptional. HTTPS url to send updates to. Use an empty string to remove webhook integration.

◆ unbanChatMember()

bool TgBot::Api::unbanChatMember ( int64_t  chatId,
int32_t  userId 
) const

Use this method to unban a previously kicked user in a supergroup.

Parameters
chatIdUnique identifier for the target group.
userIdUnique identifier of the target user.
Returns
True on success

Friends And Related Function Documentation

◆ Bot

friend class Bot
friend

Definition at line 56 of file Api.h.


The documentation for this class was generated from the following file: