Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: store data between states #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Aaaaaaaaaaann
Copy link

Данные автоматически сохраняются между состояниями

Теперь доступно добавление значений в storage без потери предыдущих значений.

async def process_first_step(message: IncomingMessage, bot: Bot) -> None:
    first_input = message.body

    await message.state.fsm.change_state(State.second_step, first_input=first_input)


@fsm.on(State.second_step)
async def process_second_step(message: IncomingMessage, bot: Bot) -> None:
    second_input = message.body

    await message.state.fsm.change_state(State.third_step, second_input=second_input)

    print(message.state.fsm_storage)
    # namespace(first_input=<value>, second_input=<value>)

Значения хранятся в storagе, пока не будет вызван метод FSM.drop_state().

Перезапись значений в storagе также доступна.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants