14 struct ChosenInlineResult;
17 struct PreCheckoutQuery;
20 struct ChatMemberUpdated;
21 struct ChatJoinRequest;
22 struct MessageReactionUpdated;
23 struct MessageReactionCountUpdated;
24 struct ChatBoostUpdated;
25 struct ChatBoostRemoved;
30 std::vector<Ptr<Update>> m_updates{};
31 std::int32_t m_lastUpdateId{};
32 std::atomic<bool> m_running{};
37 explicit Bot(
const std::string& token);
161 void dispatch(const
Ptr<
Update>& update);
166 void dispatchMessage(const
Ptr<
Message>& message);
Api Methods https://core.telegram.org/bots/api#available-methods.
virtual void onCallbackQuery(const Ptr< CallbackQuery > &callbackQuery)
Called when a new incoming callback query is received.
virtual void onChatJoinRequest(const Ptr< ChatJoinRequest > &chatJoinRequest)
Called when a request to join the chat has been sent.
bool isRunning() const noexcept
Returns true if the Bot long polling is currently running.
Bot(const std::string &token)
Constructs a new Bot object.
virtual void onChatBoostRemoved(const Ptr< ChatBoostRemoved > &chatBoostRemoved)
Called when a boost was removed from a chat.
virtual void onCommand(const Ptr< Message > &command)
Called when a new command is received (messages with leading '/' char).
const Ptr< Api > & api() const noexcept
Returns Api object.
virtual void onUnknownCommand(const Ptr< Message > &message)
Called when an unknown command is received (messages with leading '/' char).
virtual void onMessageReactionCountUpdated(const Ptr< MessageReactionCountUpdated > &messageReactionCount)
Called when reactions to a message with anonymous reactions were changed.
virtual void onPoll(const Ptr< Poll > &poll)
Called when a new poll state is received.
virtual void onLongPollError(const std::string &errorMessage, ErrorCode errorCode)
Called when the long polling getUpdates fails.
void stop()
Stop the long polling.
virtual void onChatMember(const Ptr< ChatMemberUpdated > &chatMemberUpdated)
Called when a chat member's status was updated in a chat.
virtual void onMessageReactionUpdated(const Ptr< MessageReactionUpdated > &messageReaction)
Called when a reaction to a message was changed by a user.
virtual void onMyChatMember(const Ptr< ChatMemberUpdated > &myChatMemberUpdated)
Called when the bot's chat member status was updated in a chat.
virtual void onInlineQuery(const Ptr< InlineQuery > &inlineQuery)
Called when a new incoming inline query is received.
virtual void onAnyMessage(const Ptr< Message > &message)
Called when a new message is received of any kind - text, photo, sticker, etc.
const Ptr< Api > & getApi() const noexcept
Returns Api object.
virtual void onPreCheckoutQuery(const Ptr< PreCheckoutQuery > &preCheckoutQuery)
Called when a new incoming pre-checkout query is received. Contains full information about checkout.
virtual void onChosenInlineResult(const Ptr< ChosenInlineResult > &chosenInlineResult)
Called when the result of an inline query that was chosen by a user and sent to their chat partner.
virtual void onStop()
Called when Bot is about to be stopped (triggered by Bot::stop()) Cleanup your code in this callback ...
virtual void onChatBoostUpdated(const Ptr< ChatBoostUpdated > &chatBoostUpdated)
Called when a chat boost was added or changed.
virtual void onStart()
Called before Bot starts receiving updates (triggered by Bot::start()) Use this callback to initializ...
virtual void onShippingQuery(const Ptr< ShippingQuery > &shippingQuery)
Called when a new incoming shipping query is received.
virtual void onNonCommandMessage(const Ptr< Message > &message)
Called when a non-command message is received of any kind - text, photo, sticker, etc.
virtual void onPollAnswer(const Ptr< PollAnswer > &pollAnswer)
Called when a user changed their answer in a non-anonymous poll.
void start()
Start the long polling.
virtual void onEditedMessage(const Ptr< Message > &editedMessage)
Called when a new version of a message that is known to the bot and was edited.
ErrorCode
https://core.telegram.org/api/errors
This object represents a message. https://core.telegram.org/bots/api#message.
This object represents an incoming update. At most one of the optional parameters can be present in a...