Answer the question
In order to leave comments, you need to log in
How to make the bot wait for a response at a certain moment?
How can I implement waiting for a response from the user at a certain moment in a telegram bot? For example, like BotFather in the attached image.
The bottom line is this: the user clicks on a certain button, he is prompted to enter the name of the task, he sends a message and the bot writes this message to the database. How to write to the database, I understand, I can not only understand how to get the user's message.
@bot.callback_query_handler(func=lambda call: True)
def callback_logic(call):
if call.data == 'toDoList':
todo = todolist.show_list(u_id=call.message.chat.id)
text = '\n'.join([f'{todo_task}' for todo_task, in todo])
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
text='Список твоих дел: \n\n' + text, reply_markup=toDoKeyboard)
elif call.data == 'events':
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
text='Список мероприятий: ', reply_markup=eventsKeyboard)
elif call.data == 'schedule':
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
text='Расписание: ', reply_markup=scheduleKeyboard)
elif call.data == 'back':
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
text='Главное меню', reply_markup=menu)
elif call.data == 'addTask':
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
text='Введите название задачи', reply_markup=toDoSubKeyboard)
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