Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
Functions
API methods

Functions

bool getUpdates (std::vector< types::Update > &updates, const uint_fast32_t offset=0, const uint_fast32_t limit=100, const uint_fast32_t timeout=60)
 Receive incoming updates using polling (short or long polling based on timeout) More...
 
std::experimental::optional< const class types::MessagesendMessage (const int_fast64_t chat_id, const std::string &text, const std::string &reply_markup="", const EParseMode parse_mode=EParseMode::HTML, const bool disable_web_page_preview=true, const bool disable_notification=false, const int_fast32_t reply_to_message_id=0)
 Send a message to a specified chat. (https://core.telegram.org/bots/api#sendmessage) More...
 
std::experimental::optional< const class types::MessagesendMessage (const std::string &chat_id, const std::string &text, const std::string &reply_markup="", const EParseMode parse_mode=EParseMode::HTML, const bool disable_web_page_preview=true, const bool disable_notification=false, const int_fast32_t reply_to_message_id=0)
 Send a message to a specified chat. (https://core.telegram.org/bots/api#sendmessage) More...
 
std::experimental::optional< const class types::MessagesendMessage (const std::string &text, const std::string &reply_markup="", const EParseMode parse_mode=EParseMode::HTML, const bool disable_web_page_preview=true, const bool disable_notification=false, const int_fast32_t reply_to_message_id=0)
 Send a message to a specified chat. More...
 
bool answerCallbackQuery (const std::string &text, bool show_alert=false, uint32_t cache_time=0, const std::string &url="")
 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...
 
std::experimental::optional< const class types::MessageeditMessageText (const int_fast64_t chat_id, const uint_fast32_t message_id, const std::string &text, const std::string &reply_markup="", const EParseMode parse_mode=static_cast< EParseMode >(1), const bool disable_web_page_preview=true)
 Edit text (and reply markup) of a message sent by the bot. More...
 
std::experimental::optional< const class types::MessageeditMessageText (const std::string &chat_id, const uint_fast32_t message_id, const std::string &text, const std::string &reply_markup="", const EParseMode parse_mode=static_cast< EParseMode >(1), const bool disable_web_page_preview=true)
 Edit text (and reply markup) of a message sent by the bot. More...
 
std::experimental::optional< const class types::MessageeditMessageText (const uint_fast32_t message_id, const std::string &text, const std::string &reply_markup="", const EParseMode parse_mode=static_cast< EParseMode >(1), const bool disable_web_page_preview=true)
 Edit text (and reply markup) of a message sent by the bot. More...
 
bool editMessageText (const std::string &inline_message_id, const std::string &text, const std::string &reply_markup="", const EParseMode parse_mode=static_cast< EParseMode >(1), const bool disable_web_page_preview=true)
 Edit text (and reply markup) of a message sent via the bot (using inline queries). More...
 
std::experimental::optional< const class types::MessageeditMessageCaption (const int_fast64_t chat_id, const uint_fast32_t message_id, const std::string &caption="", const std::string &reply_markup="")
 Edit captions of messages sent by the bot. More...
 
std::experimental::optional< const class types::MessageeditMessageCaption (const std::string &chat_id, const uint_fast32_t message_id, const std::string &caption="", const std::string &reply_markup="")
 Edit captions of messages sent by the bot. More...
 
std::experimental::optional< const class types::MessageeditMessageCaption (const uint_fast32_t message_id, const std::string &caption="", const std::string &reply_markup="")
 Edit captions of messages sent by the bot. More...
 
bool editMessageCaption (const std::string &inline_message_id, const std::string &caption, const std::string &reply_markup="")
 Edit captions of messages sent via the bot (using inline_queries). More...
 
std::experimental::optional< const class types::MessageeditMessageReplyMarkup (const int_fast64_t chat_id, const uint_fast32_t message_id, const std::string &reply_markup="")
 Edit only the reply markup of a message sent by the the bot. More...
 
std::experimental::optional< const class types::MessageeditMessageReplyMarkup (const std::string &chat_id, const uint_fast32_t message_id, const std::string &reply_markup="")
 Edit only the reply markup of a message sent by the the bot. More...
 
std::experimental::optional< const class types::MessageeditMessageReplyMarkup (const uint_fast32_t message_id, const std::string &reply_markup="")
 Edit only the reply markup of a message sent by the the bot. More...
 
bool editMessageReplyMarkup (const std::string &inline_message_id, const std::string &reply_markup="")
 
bool answerInlineQuery (const Json::Value &results, const uint_fast16_t cache_time=300, const bool is_personal=false, const std::string &next_offset="", const std::string &switch_pm_text="", const std::string &switch_pm_paramter="")
 Answer an inline query. (https://core.telegram.org/bots/api#answerinlinequery) More...
 

Detailed Description

Function Documentation

◆ answerCallbackQuery()

bool answerCallbackQuery ( const std::string &  text,
bool  show_alert = false,
uint32_t  cache_time = 0,
const std::string &  url = "" 
)

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
textText of the notification. If not specified, nothing will be shown to the user, 0-200 characters
show_alertIf true, an alert will be shown by the client instead of a notification at the top of the chat screen.
cache_timeThe maximum amount of time in seconds that the result of the callback query may be cached client-side.
URLthat 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.
Returns
On success, True is returned.

◆ answerInlineQuery()

bool answerInlineQuery ( const Json::Value &  results,
const uint_fast16_t  cache_time = 300,
const bool  is_personal = false,
const std::string &  next_offset = "",
const std::string &  switch_pm_text = "",
const std::string &  switch_pm_paramter = "" 
)

Answer an inline query. (https://core.telegram.org/bots/api#answerinlinequery)

Parameters
inline_query_idUnique identifier for the answered query
resultsJSON serialized array of the results for the inline query. Use InlineQueryResults to create them.
cache_timeThe maximum amount of time in seconds that the result of the inline query may be cached on the server.
is_personalPass True, if results may be cached on the server side only for the user that sent the query.
next_offsetPass 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.
switch_pm_textIf 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
switch_pm_paramterParameter for the start message sent to the bot when user presses the switch button.
Returns
True on success, false otherwise.

◆ editMessageCaption() [1/4]

std::experimental::optional<const class types::Message> editMessageCaption ( const int_fast64_t  chat_id,
const uint_fast32_t  message_id,
const std::string &  caption = "",
const std::string &  reply_markup = "" 
)

Edit captions of messages sent by the bot.

Leaving reply_markup empty remove it from the edited message. (https://core.telegram.org/bots/api#editmessagecaption)

Parameters
chat_idUnique identifier for the target chat.
captionNew caption of the message.
reply_markupInline keyboard object.
Returns
On success, the edited message.

◆ editMessageCaption() [2/4]

std::experimental::optional<const class types::Message> editMessageCaption ( const std::string &  chat_id,
const uint_fast32_t  message_id,
const std::string &  caption = "",
const std::string &  reply_markup = "" 
)

Edit captions of messages sent by the bot.

Parameters
chat_idUsername of the target channel or group (in the format @channelusername). (https://core.telegram.org/bots/api#editmessagecaption)

◆ editMessageCaption() [3/4]

std::experimental::optional<const class types::Message> editMessageCaption ( const uint_fast32_t  message_id,
const std::string &  caption = "",
const std::string &  reply_markup = "" 
)

Edit captions of messages sent by the bot.

The chat selected will be the chat from where the current update was received. (https://core.telegram.org/bots/api#editmessagecaption)

◆ editMessageCaption() [4/4]

bool editMessageCaption ( const std::string &  inline_message_id,
const std::string &  caption,
const std::string &  reply_markup = "" 
)

Edit captions of messages sent via the bot (using inline_queries).

Leaving reply_markup empty remove it from the edited message. (https://core.telegram.org/bots/api#editmessagecaption)

Parameters
inline_message_idIdentifier of the inline message.
captionNew caption of the message.
reply_markupInline Keyboard object.
Returns
True on success, false otherwise.

◆ editMessageReplyMarkup() [1/4]

std::experimental::optional<const class types::Message> editMessageReplyMarkup ( const int_fast64_t  chat_id,
const uint_fast32_t  message_id,
const std::string &  reply_markup = "" 
)

Edit only the reply markup of a message sent by the the bot.

Leaving reply_markup empty remove it from the edited message. (https://core.telegram.org/bots/api#editmessagereplymarkup)

Parameters
chat_idUnique identifier for the target chat.
message_idUnique identifier of the sent message.
reply_markupNew inline keyboard object.
Returns
On success, the edited message.

◆ editMessageReplyMarkup() [2/4]

std::experimental::optional<const class types::Message> editMessageReplyMarkup ( const std::string &  chat_id,
const uint_fast32_t  message_id,
const std::string &  reply_markup = "" 
)

Edit only the reply markup of a message sent by the the bot.

Parameters
chat_idUsername of the target channel or group (in the format @channelusername). (https://core.telegram.org/bots/api#editmessagereplymarkup)
See also
editMessageReplyMarkup

◆ editMessageReplyMarkup() [3/4]

std::experimental::optional<const class types::Message> editMessageReplyMarkup ( const uint_fast32_t  message_id,
const std::string &  reply_markup = "" 
)

Edit only the reply markup of a message sent by the the bot.

The chat selected will be the chat from where the current update was received. (https://core.telegram.org/bots/api#editmessagereplymarkup)

See also
editMessageReplyMarkup

◆ editMessageReplyMarkup() [4/4]

bool editMessageReplyMarkup ( const std::string &  inline_message_id,
const std::string &  reply_markup = "" 
)

Edit only the reply markup of a message sent via the the bot (using inline queries). Leaving reply_markup empty remove keyboards from the message edited. (https://core.telegram.org/bots/api#editmessagereplymarkup)

Parameters
inline_message_idIdentifier of the inline message.
reply_markupNew inline keyboard object.
Returns
True on success, false otherwise.

◆ editMessageText() [1/4]

std::experimental::optional<const class types::Message> editMessageText ( const int_fast64_t  chat_id,
const uint_fast32_t  message_id,
const std::string &  text,
const std::string &  reply_markup = "",
const EParseMode  parse_mode = static_cast< EParseMode >(1),
const bool  disable_web_page_preview = true 
)

Edit text (and reply markup) of a message sent by the bot.

Leaving reply_markup empty remove it from the edited message. (https://core.telegram.org/bots/api#editmessagetext)

Parameters
chat_idUnique identifier for the target chat.
message_idUnique identifier of the sent message.
textNew text of the message.
reply_markupInline keyboard object.
parse_modeSend an enum of type ParseMode.
disable_web_page_previewDisables link previews for links in this message.
Returns
On success, the edited message.

◆ editMessageText() [2/4]

std::experimental::optional<const class types::Message> editMessageText ( const std::string &  chat_id,
const uint_fast32_t  message_id,
const std::string &  text,
const std::string &  reply_markup = "",
const EParseMode  parse_mode = static_cast< EParseMode >(1),
const bool  disable_web_page_preview = true 
)

Edit text (and reply markup) of a message sent by the bot.

Parameters
chat_idUsername of the target channel or group (in the format @channelusername).
See also
editMessageText

◆ editMessageText() [3/4]

std::experimental::optional<const class types::Message> editMessageText ( const uint_fast32_t  message_id,
const std::string &  text,
const std::string &  reply_markup = "",
const EParseMode  parse_mode = static_cast< EParseMode >(1),
const bool  disable_web_page_preview = true 
)

Edit text (and reply markup) of a message sent by the bot.

The chat selected will be the chat from where the current update was received. (https://core.telegram.org/bots/api#editmessagetext)

See also
editMessageText

◆ editMessageText() [4/4]

bool editMessageText ( const std::string &  inline_message_id,
const std::string &  text,
const std::string &  reply_markup = "",
const EParseMode  parse_mode = static_cast< EParseMode >(1),
const bool  disable_web_page_preview = true 
)

Edit text (and reply markup) of a message sent via the bot (using inline queries).

Leaving reply_markup empty remove it from the edited message. (https://core.telegram.org/bots/api#editmessagetext)

Parameters
inline_message_idIdentifier of the inline message.
textNew text of the message.
reply_markupInline keyboard object.
parse_modeSend an enum of type ParseMode.
disable_web_page_previewDisables link previews for links in this message.
Returns
True on success, false otherwise.

◆ getUpdates()

bool getUpdates ( std::vector< types::Update > &  updates,
const uint_fast32_t  offset = 0,
const uint_fast32_t  limit = 100,
const uint_fast32_t  timeout = 60 
)

Receive incoming updates using polling (short or long polling based on timeout)

Parameters
updatesPushes all the updates on the back of a vector.
offsetIdentifier 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. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten.
limitLimits the number of updates to be retrieved. Values between 1—100 are accepted.
timeoutTimeout in seconds for long polling.
Returns
True if there are new updates, false otherwise

◆ sendMessage() [1/3]

std::experimental::optional<const class types::Message> sendMessage ( const int_fast64_t  chat_id,
const std::string &  text,
const std::string &  reply_markup = "",
const EParseMode  parse_mode = EParseMode::HTML,
const bool  disable_web_page_preview = true,
const bool  disable_notification = false,
const int_fast32_t  reply_to_message_id = 0 
)

Send a message to a specified chat. (https://core.telegram.org/bots/api#sendmessage)

Parameters
chat_idUnique identifier for the target chat.
textText of the message to be sent.
reply_markupAdditional interface options. Use InlineKeyboard class to create a reply markup.
parse_modeSend an enum of type ParseMode.
disable_web_page_previewDisables link previews for links in this message.
disable_notificationSends the message silently.
reply_to_message_idIf the message is a reply, Id of the original. message.
Returns
On success, the message sent.

◆ sendMessage() [2/3]

std::experimental::optional<const class types::Message> sendMessage ( const std::string &  chat_id,
const std::string &  text,
const std::string &  reply_markup = "",
const EParseMode  parse_mode = EParseMode::HTML,
const bool  disable_web_page_preview = true,
const bool  disable_notification = false,
const int_fast32_t  reply_to_message_id = 0 
)

Send a message to a specified chat. (https://core.telegram.org/bots/api#sendmessage)

See also
sendMessage

◆ sendMessage() [3/3]

std::experimental::optional<const class types::Message> sendMessage ( const std::string &  text,
const std::string &  reply_markup = "",
const EParseMode  parse_mode = EParseMode::HTML,
const bool  disable_web_page_preview = true,
const bool  disable_notification = false,
const int_fast32_t  reply_to_message_id = 0 
)

Send a message to a specified chat.

Parameters
chat_idUsername of the target channel or group (in the format @channelusername). (https://core.telegram.org/bots/api#sendmessage)
See also
sendMessage