Answer the question
In order to leave comments, you need to log in
How to understand what state or group of states the telegram bot is in?
I am writing a bot in telegrams and there was a need to somehow find out what state the bot is in when the user clicks on the inline button, please tell me how this can be done?
class registration(StatesGroup):
waiting_for_name = State()
waiting_for_age = State()
waiting_for_sex = State()
waiting_for_city = State()
waiting_for_interest = State()
waiting_for_voice = State()
Answer the question
In order to leave comments, you need to log in
class registration(StatesGroup):
waiting_for_name = State()
waiting_for_age = State()
waiting_for_sex = State()
waiting_for_city = State()
waiting_for_interest = State()
waiting_for_voice = State()
async def check_state(message: types.Message, state: FSMContext):
current_state = await state.get_state() # текущее машинное состояние пользователя
if current_state in registration: # registration - название класса состояний
print('Пользователь в одном из состояний регистрации')
if current_state == 'registration:waiting_for_name':
print('Пользователь находиться в конкретном состоянии - waiting_for_name из класса registration')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question