Skip to content

Commit

Permalink
Updated README.md example
Browse files Browse the repository at this point in the history
  • Loading branch information
baderouaich committed Sep 26, 2023
1 parent d8f152f commit a1d1dba
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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>& 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> &message) override {
std::cout << __func__ << ": " << message->text << std::endl;
}

/// Called when a new command is received (messages with leading '/' char).
void onCommand(const Ptr<Message>& command) override {
std::cout << __func__ << ": " << command->text << std::endl;
if(command->text == "/stop") {
Expand All @@ -61,13 +72,35 @@ private:
}
}

void onNonCommandMessage(const Ptr<Message> &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> &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<Message>& editedMessage) override {}
/// Called when a new incoming inline query is received
void onInlineQuery(const Ptr<InlineQuery>& 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>& chosenInlineResult) override {}
/// Called when a new incoming callback query is received
void onCallbackQuery(const Ptr<CallbackQuery>& callbackQuery) override {}
/// Called when a new incoming shipping query is received.
void onShippingQuery(const Ptr<ShippingQuery>& shippingQuery) override {}
/// Called when a new incoming pre-checkout query is received. Contains full information about checkout
void onPreCheckoutQuery(const Ptr<PreCheckoutQuery>& preCheckoutQuery) override {}
/// Called when a new poll state is received.
void onPoll(const Ptr<Poll>& poll) override {}
/// Called when a user changed their answer in a non-anonymous poll.
void onPollAnswer(const Ptr<PollAnswer>& pollAnswer) override {}
/// Called when the bot's chat member status was updated in a chat.
void onMyChatMember(const Ptr<ChatMemberUpdated>& myChatMemberUpdated) override {}
/// Called when a chat member's status was updated in a chat.
void onChatMember(const Ptr<ChatMemberUpdated>& chatMemberUpdated) override {}
/// Called when a A request to join the chat has been sent.
void onChatJoinRequest(const Ptr<ChatJoinRequest>& chatJoinRequest) override {}
};

int main() {
Expand Down

0 comments on commit a1d1dba

Please sign in to comment.