N
N
Nika9802021-12-19 10:12:07
Python
Nika980, 2021-12-19 10:12:07

How to make the bot respond to the main menu for any message?

Good day. I wrote a telegram bot in Python, but when you go far into the menu, you can only go back using the / start command, which is not very convenient, I have seen bots that can return back to the main page when sending any message to the bot. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ananchenko, 2021-12-19
@Shurik24

There are 2 options to return to the main menu through a command for example / menu or create a "command" from the on_message () method that will return the user to the main menu, although if the user makes a mistake in the command, it will return him to the beginning, this is not very good
. , when creating a command from the on_message() method, be careful to make it the last command in the code, if it is the first, all commands after it will not be defined and will be ignored

K
kreeplambor, 2021-12-20
@kreeplambor

You can write in message_handler in else (if menu navigation occurs through messages or KeyboardButton) so that the function (def) of the main menu or greetings is returned

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question