Есть простой бот для опроса пользователей:
async def opros():
agcm = gspread_asyncio.AsyncioGspreadClientManager(get_creds)
employers = await get_employers(agcm)
for element in range(len(employers)):
hour = employers[element][2].split(':')[0]
users_chat_id = employers[element][1]
name = employers[element][0]
questions = await get_questions(agcm)
if datetime.now().strftime("%H") == hour:
await bot.send_message(users_chat_id, questions['q1'])
@dp.message_handler()
async def process_name(message: types.Message, state: FSMContext):
await Form.Q1.set()
async with state.proxy() as data:
data['answer1'] = message.text
await Form.next()
await message.reply(questions['q2'])
@dp.message_handler(state=Form.Q2)
async def process_gender(message: types.Message, state: FSMContext):
async with state.proxy() as data:
data['answer2'] = message.text
answer1 = data['answer1']
answer2 = data['answer2']
await write_data(agcm, name, answer1, answer2, element + 1)
await message.answer("Спасибо за ответы!")
await state.finish()
Как тут лучше добавить возможность завершение диалога досрочно не отвечая на все вопросы по команде stop?