How to break conversation when sending another command

163 Views Asked by At

I'm using PyTelegramApi library.
My bot has 4 buttons that each do a different action.
How can I break the conversation when the user click on "back" button or send another command?
For exmple:
/start -> click on new post button.
Bot: Hi, send text for the post.
User: Press back button and click on uplade photo button photo.
Bot: Hi, send your photo.
User: send photo..
Bot: it's not text, try again (because he click on new post before) + Bot: Nice photo!

How can I fix that thing?

1

There are 1 best solutions below

0
On

Just check what is the message text that user sent.

if message.text == "Back":
  # Sending a message to user like 'You are in MainMenu now.'
else:
  # ...