Answer the question
In order to leave comments, you need to log in
How to use bot_register_next_step_handler in a loop?
I have a list of items in a user's shopping cart, I need to check the quantity of the item in the cart with what is in stock. I am iterating over the elements of a list using a for loop. If the quantity in the cart is more than available, then I ask the user to answer with bot.register_next_step_handler if he wants to purchase this item. But in the course of execution, there is no waiting for a response from the user, and the code continues to be executed further along the cycle. How can I implement this functionality in the for loop or can it be done by other methods?
for i in row:
elif int(num[0])<int(i[5]): #Если количество товара в наличии меньше, чем в корзине
msg = bot.send_message(message.chat.id, "К сожаление товар " + str(i[3]) + " из категории " + str(i[2]) + находится в меньшем
количестве в наличии, чем у вас в корзине (" + str(num[0]) + " шт.) \nЖелаете приобрести товар в данном количестве?",
reply_markup = formation)
messageidfordel = msg.message_id
def moreavailable(message):
if solution == 'Нет':
...
bot.register_next_step_handler(msg, moreavailable)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question