why it doesn't move to the last state(LowPrice.result_without_photo)? for example, if I use print in each handlers, it print it except the last one.
Of course I can not to move to the last state and write this func in the current state, but this code simplified, just fo example, it has more lines, that is why I want to use a separate state, just to make code more readable
my handlers:
@dp.message_handler(Command("lowprice"))
async def choose_city(message: types.Message):
await message.answer('Write city')
await LowPrice.city.set()
@dp.message_handler(state=LowPrice.city)
async def hotels_quantity(message: types.Message, state: FSMContext):
answer = message.text
await state.update_data(city=answer)
await message.answer('How many hotels do I need to show you?')
await LowPrice.quantity_hotels.set()
@dp.message_handler(state=LowPrice.quantity_hotels)
async def if_need_photo(message: types.Message, state: FSMContext):
answer = message.text
await state.update_data(quantity_hotels=answer)
await message.answer('Do I need to show you hotel photos?')
await LowPrice.photo.set()
@dp.message_handler(state=LowPrice.photo)
async def get_answer_about_photo(message: types.Message, state: FSMContext):
answer = message.text
await state.update_data(if_photo_need=answer)
if answer == 'Yes':
await message.answer('How many photos to show?')
await LowPrice.quantity_photo.set()
elif answer == 'No':
await message.answer('Fine, I am starting to find hotels')
await LowPrice.result_without_photo.set()
@dp.message_handler(state=LowPrice.result_without_photo)
async def result_without_photo(message: types.Message, state: FSMContext):
data = await state.get_data()
city_id = get_id_city(data)
await message.answer(f'city ID{city_id}')
my states:
class LowPrice(StatesGroup):
start = State()
city = State()
date = State()
quantity_hotels = State()
photo = State()
result_without_photo = State()
quantity_photo = State()
Because user need to write something for help you to handle message in result_without_photo
function.
Are you sure that you really want it?
Seems you just need to execute content of result_without_photo
after No
answer instead of awaiting another one communication from user.