14 struct ChosenInlineResult;
17 struct PreCheckoutQuery;
20 struct ChatMemberUpdated;
21 struct ChatJoinRequest;
22 struct MessageReactionUpdated;
23 struct MessageReactionCountUpdated;
24 struct ChatBoostUpdated;
25 struct ChatBoostRemoved;
26 struct BusinessConnection;
27 struct BusinessMessagesDeleted;
28 struct PaidMediaPurchased;
33 std::vector<Ptr<Update>> m_updates{};
34 std::int32_t m_lastUpdateId{};
35 std::atomic<bool> m_running{};
40 explicit Bot(
const std::string& token);
51#pragma region Lifecycle
59#pragma endregion Lifecycle
61#pragma region Messages
82#pragma endregion Messages
92#pragma endregion Channel
94#pragma region Business
111#pragma endregion Business
113#pragma region MessageReaction
125#pragma endregion MessageReaction
127#pragma region InlineMode
149#pragma endregion InlineMode
151#pragma region Payments
155#pragma endregion Payments
167#pragma endregion Poll
192#pragma endregion Chat
199#pragma endregion Errors
213 void dispatch(const
Ptr<
Update>& update);
218 void dispatchMessages(const
Ptr<
Update>& update);
222 void dispatchChannel(const
Ptr<
Update>& update);
226 void dispatchBusiness(const
Ptr<
Update>& update);
230 void dispatchMessageReaction(const
Ptr<
Update>& update);
234 void dispatchInlineMode(const
Ptr<
Update>& update);
238 void dispatchPayments(const
Ptr<
Update>& update);
242 void dispatchPoll(const
Ptr<
Update>& update);
246 void dispatchChat(const
Ptr<
Update>& update);
Api Methods https://core.telegram.org/bots/api#available-methods.
virtual void onChatBoostUpdated(const Ptr< ChatBoostUpdated > &chatBoost)
Called when a chat boost was added or changed.
virtual void onBusinessConnection(const Ptr< BusinessConnection > &businessConnection)
Called when the bot was connected to or disconnected from a business account, or a user edited an exi...
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 onCommand(const Ptr< Message > &command)
Called when a new command is received (messages with leading '/' char).
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 onChannelPostEdited(const Ptr< Message > &editedChannelPost)
Called when a new version of a channel post that is known to the bot and was edited.
virtual void onLongPollError(const std::string &errorMessage, ErrorCode errorCode)
Called when the long polling getUpdates fails.
void stop()
Stop the long polling.
virtual void onChannelPost(const Ptr< Message > &channelPost)
Called when a new incoming channel post of any kind (text, photo, sticker, etc.) is received.
virtual void onMessageReactionUpdated(const Ptr< MessageReactionUpdated > &messageReaction)
Called when a reaction to a message was changed by a user.
const Ptr< Api > & api() const noexcept
Returns Api object.
virtual void onBusinessMessage(const Ptr< Message > &businessMessage)
Called when a new message from a connected business account is received.
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.
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 onMessageEdited(const Ptr< Message > &editedMessage)
Called when a new version of a message that is known to the bot and was edited.
virtual void onStop()
Called when Bot is about to be stopped (triggered by Bot::stop()) Cleanup your code in this callback ...
virtual void onMyChatMemberUpdated(const Ptr< ChatMemberUpdated > &myChatMember)
Called when the bot's chat member status was updated in a chat.
virtual void onChatMemberUpdated(const Ptr< ChatMemberUpdated > &chatMember)
Called when a chat member's status was updated in a chat.
virtual void onStart()
Bot Callbacks.
virtual void onShippingQuery(const Ptr< ShippingQuery > &shippingQuery)
Called when a new incoming shipping query is received.
virtual void onChatBoostRemoved(const Ptr< ChatBoostRemoved > &removedChatBoost)
Called when a boost was removed from a chat.
const Ptr< Api > & getApi() const noexcept
Returns Api object.
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.
virtual void onPaidMediaPurchased(const Ptr< PaidMediaPurchased > &purchasedPaidMedia)
Called when a user purchased paid media with a non-empty payload sent by the bot in a non-channel cha...
virtual void onBusinessMessageEdited(const Ptr< Message > &editedBusinessMessage)
Called when a new version of a message from a connected business account is received.
void start()
Start the long polling.
virtual void onBusinessMessagesDeleted(const Ptr< BusinessMessagesDeleted > &deletedBusinessMessages)
Called when Messages were deleted from a connected business account.
ErrorCode
https://core.telegram.org/api/errors
This object represents an incoming update. At most one of the optional parameters can be present in a...