diff --git a/README.md b/README.md index db385cbc5..495675246 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ public: MyBot() : Bot("BOT_TOKEN_FROM_BOTH_FATHER") {} private: + /// Called before Bot starts receiving updates (triggered by Bot::start()) + /// Use this callback to initialize your code, set commands.. void onStart() override { std::cout << __func__ << std::endl; @@ -44,15 +46,24 @@ private: commands.push_back(stop); getApi()->setMyCommands(commands); // The above commands will be shown in the bot chat menu (bottom left) } - + + /// Called when Bot is about to be stopped (triggered by Bot::stop()) + /// Cleanup your code in this callback (close handles, backup data...) void onStop() override { std::cout << __func__ << std::endl; } + /// Called when a new message is received of any kind - text, photo, sticker, etc. void onAnyMessage(const Ptr& message) override { std::cout << __func__ << ": " << message->text << std::endl; } + /// Called when a non-command message is received of any kind - text, photo, sticker, etc. + void onNonCommandMessage(const Ptr &message) override { + std::cout << __func__ << ": " << message->text << std::endl; + } + + /// Called when a new command is received (messages with leading '/' char). void onCommand(const Ptr& command) override { std::cout << __func__ << ": " << command->text << std::endl; if(command->text == "/stop") { @@ -61,13 +72,35 @@ private: } } - void onNonCommandMessage(const Ptr &message) override { - std::cout << __func__ << ": " << message->text << std::endl; - } - + /// Called when an unknown command is received (messages with leading '/' char). + /// Known commands are set with Bot::setCommands() void onUnknownCommand(const Ptr &message) override { std::cout << __func__ << ": " << message->text << std::endl; } + + // Other callbacks (optional overload) + /// Called when a new version of a message that is known to the bot and was edited + void onEditedMessage(const Ptr& editedMessage) override {} + /// Called when a new incoming inline query is received + void onInlineQuery(const Ptr& inlineQuery) override {} + /// Called when the result of an inline query that was chosen by a user and sent to their chat partner. + void onChosenInlineResult(const Ptr& chosenInlineResult) override {} + /// Called when a new incoming callback query is received + void onCallbackQuery(const Ptr& callbackQuery) override {} + /// Called when a new incoming shipping query is received. + void onShippingQuery(const Ptr& shippingQuery) override {} + /// Called when a new incoming pre-checkout query is received. Contains full information about checkout + void onPreCheckoutQuery(const Ptr& preCheckoutQuery) override {} + /// Called when a new poll state is received. + void onPoll(const Ptr& poll) override {} + /// Called when a user changed their answer in a non-anonymous poll. + void onPollAnswer(const Ptr& pollAnswer) override {} + /// Called when the bot's chat member status was updated in a chat. + void onMyChatMember(const Ptr& myChatMemberUpdated) override {} + /// Called when a chat member's status was updated in a chat. + void onChatMember(const Ptr& chatMemberUpdated) override {} + /// Called when a A request to join the chat has been sent. + void onChatJoinRequest(const Ptr& chatJoinRequest) override {} }; int main() {