Answer the question
In order to leave comments, you need to log in
What is the standard bot algorithm?
Hello!
There is such a question, here is a piece of the bot, the problem is that it works out everything at once, you can somehow do it so that when the user presses the start command, he was first prompted to enter a password, after entering it already worked out the rest. and here it turns out that as soon as I enter start, it recognizes the command and launches the desired function, but the start command still recognizes it as well as text.
@bot.message_handler(commands = ["start"])
def numberone(message):
umber(message)
@bot.message_handler(content_type = ["text"])
def umber(message):
bot.send_message(message.chat.id,"password pls")
if message.text == 111:
bot.send_message(message.chat.id,"norm")
else:
bot.send_message(message.chat.id,"oops")
Answer the question
In order to leave comments, you need to log in
We get all the commands requiring registration in one place. Check if you are already registered. If not, send an invitation.
Handle login attempts separately.
It is necessary to store user states and look at them when and what to give, what to do.
There were many similar questions. The answers are in this thread.
it is possible to check whether a person has access or not through the lambda in the decarator, but the problem remains, for example, if he has the right, there is a variable new_doc = 0
after checking the password, we do new_doc+=1
and then, in theory, the person should be offered from the trace function to enter something else to save,
but decarator over a function like this
@bot.message_handker(func=lambda new_doc: new_doc == 1)
doesn't work even though new_doc is 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question