Вот первый хендлэр:
@dp.message_handler(commands=['start'])
async def start_menu(message: types.Message):
global paste_username, paste, username, math_equation_result
await Mydialog.captcha1.set()
CAPCTHA_SIZE_NUM = 2
generator = CaptchaGenerator(CAPCTHA_SIZE_NUM)
captcha = generator.gen_captcha_image(difficult_level=3)
math_captcha = generator.gen_math_captcha_image(difficult_level=2)
image = captcha.image
characters = captcha.characters
math_image = math_captcha.image
math_equation_string = math_captcha.equation_str
math_equation_result = math_captcha.equation_result
image.save("captcha.png", "png")
math_image.save("captcha.png", "png")
photo = open("captcha.png", "rb")
await bot.send_photo(chat_id=message.from_user.id, photo=photo)
await message.answer('Чтобы начать работу, решите математический пример!')
print(math_image)
print(math_equation_string)
print(math_equation_result)
username = message.from_user.username
Второй хэндлэр (после elif '/start' in message.text нужно вызвать выполнения функции start_menu с первого хендлэра):
@dp.message_handler(state=Mydialog.confirm)
async def agree(message: types.Message):
try:
if '⛔️ Отмена' in message.text:
await message.answer('Всего хорошего!', reply_markup = ReplyKeyboardRemove())
elif '✅ Согласен' in message.text:
await message.answer('Чтобы продолжить, подпишись на наш Telegram : \n@test_prize \n<link>', reply_markup=telegram_buttons)
await Mydialog.telegram.set()
elif '/start' in message.text:
start_menu()
except:
pass