D
D
dw022021-09-07 17:43:43
Python
dw02, 2021-09-07 17:43:43

How to assign a variable to each answer for further python(aiogram) output?

works on aiogram python , don't know how to use state machine

@dp.message_handler(text=['Online order'])
async def process_command_1(message: types.Message):
await message.reply("Select products :", reply_markup=inline_kb )

@dp.callback_query_handler(lambda c: c.data == 'convert')
async def process_callback_button1(callback_query: types.CallbackQuery , state: FSMContext):
await bot.answer_callback_query(callback_query.id)
await bot.send_message(callback_query.from_user .id, 'Number of sides?', reply_markup=inline_kb1)
async with state.proxy() as data:
data['ref1'] = ref_id_1lv
data['ref2'] = ref_id_2lv
@dp.callback_query_handler(lambda c: c.data == 'allpanton')
async def process_callback_button1(callback_query: types.CallbackQuery , state: FSMContext):
await bot.answer_callback_query(callback_query.id)
await bot.send_message(callback_query.from_user. id, 'Select size ?', reply_markup=inline_kb2)
@dp.callback_query_handler(lambda c: c.data == 'sizew1')
async def process_callback_button1(callback_query: types.CallbackQuery , state: FSMContext):
await bot.answer_callback_query(callback_query .id)
await bot.send_message(callback_query.from_user.id, 'Choose number ?',reply_markup=inline_kb3)
async with state.proxy() as data:
ref_id_1lv = data['ref1']
ref_id_2lv = data['ref2']
await state.finish()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-09-08
@Vindicar

Store in a DB the table of a kind the user-stage.
When a message is received, get the user's current stage, interpret the message as a response to the current stage, and then increment the stage number.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question