0

I a making a telegram bot, and the problem is that user has to accept policy and when user click accept the bot just shows loading message

Video with the problem: https://drive.google.com/file/d/1yAZl0VDn_tisBsHAaJ2udyfnaW-G9IOH/view?usp=sharing

My code:https://github.com/user515244/code.git

CallMeStag
  • 5,467
  • 1
  • 7
  • 22
Dima
  • 15
  • 4
  • Please describe the problem clearly in the title so that it is obvious what to deal with. Thanks though for providing the code. This is how you can improve your question by adding only what is necessary, i.e. the parts where everything fails and adjacent parts dependent on them: [how to create a minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) – Anna Jun 21 '23 at 12:46

1 Answers1

0
  1. You have a typo in line 37 (confirm_correct1 instead of confirm_correct)

  2. To handle the next state, you simply need the next state, otherwise it will not be switched. This is how FSM works.

Add to your class:

state_name = State()

Add to your handlers with text=confirm_correct and text=go_back (please don't give the functions in them the same names, names should explain what the function does) the following:

@dp.callback_query_handler(text="confirm_correct", state=SomeState.state_name)

...

@dp.callback_query_handler(text="go_back", state=SomeState.state_name)

Add to handle_accept_policy setting the state:

if amount and wallet:
        await callback.message.edit_text(f"Amount: {amount}\nWallet: {wallet}\n\nIs everything correct?",
                                         reply_markup=accept_menu)

        await SomeState.state_name.set()

And that'll be it.

Anna
  • 101
  • 8