| import sys |
|
|
| states_code = """ |
| # V7: Kripto & Profil |
| waiting_crypto_type = State() |
| waiting_crypto_address = State() |
| waiting_profile_platform = State() |
| waiting_profile_username = State() |
| """ |
|
|
| |
| with open('handlers/generate.py', 'r', encoding='utf-8') as f: |
| content = f.read() |
|
|
| content = content.replace("waiting_pay_amount = State() # Summa\n", "waiting_pay_amount = State() # Summa\n" + states_code) |
|
|
| handlers_code = """ |
| # ==================== KRIPTOVALYUTA ==================== |
| |
| from keyboards.menus import crypto_type_menu, profile_platform_menu |
| |
| @router.callback_query(F.data == "qr_type:crypto") |
| async def qr_type_crypto(callback: CallbackQuery, state: FSMContext): |
| await state.set_state(GenerateQR.waiting_crypto_type) |
| await callback.message.edit_text( |
| "πͺ <b>Kriptovalyuta turini tanlang:</b>", |
| parse_mode="HTML", |
| reply_markup=crypto_type_menu(), |
| ) |
| await callback.answer() |
| |
| @router.callback_query(F.data.startswith("crypto:"), GenerateQR.waiting_crypto_type) |
| async def process_crypto_type(callback: CallbackQuery, state: FSMContext): |
| c_type = callback.data.split(":")[1] |
| await state.update_data(crypto_type=c_type) |
| await state.set_state(GenerateQR.waiting_crypto_address) |
| await callback.message.edit_text( |
| f"π <b>{c_type.upper()} hamyon manzilini yuboring:</b>", |
| parse_mode="HTML", |
| reply_markup=cancel_keyboard(), |
| ) |
| await callback.answer() |
| |
| @router.message(GenerateQR.waiting_crypto_address) |
| async def process_crypto_address(message: Message, state: FSMContext, bot: Bot): |
| address = message.text.strip() if message.text else "" |
| if not address: |
| await message.answer("β Hamyon manzilini yuboring.") |
| return |
| data = await state.get_data() |
| c_type = data["crypto_type"] |
| qr_data = format_crypto(c_type, address) |
| await generate_and_send(message, qr_data, "crypto", state, bot) |
| |
| |
| # ==================== IJTIMOIY PROFIL ==================== |
| |
| @router.callback_query(F.data == "qr_type:profile") |
| async def qr_type_profile(callback: CallbackQuery, state: FSMContext): |
| await state.set_state(GenerateQR.waiting_profile_platform) |
| await callback.message.edit_text( |
| "π€ <b>Ijtimoiy tarmoqni tanlang:</b>", |
| parse_mode="HTML", |
| reply_markup=profile_platform_menu(), |
| ) |
| await callback.answer() |
| |
| @router.callback_query(F.data.startswith("profile:"), GenerateQR.waiting_profile_platform) |
| async def process_profile_platform(callback: CallbackQuery, state: FSMContext): |
| p_format = callback.data.split(":")[1] |
| await state.update_data(profile_platform=p_format) |
| await state.set_state(GenerateQR.waiting_profile_username) |
| await callback.message.edit_text( |
| f"π€ <b>{p_format.capitalize()} profilingiz username'ini (yoki havolasini) yuboring:</b>\\n\\nMasalan: <code>@username</code>", |
| parse_mode="HTML", |
| reply_markup=cancel_keyboard(), |
| ) |
| await callback.answer() |
| |
| @router.message(GenerateQR.waiting_profile_username) |
| async def process_profile_username(message: Message, state: FSMContext, bot: Bot): |
| username = message.text.strip() if message.text else "" |
| if not username: |
| await message.answer("β Iltimos username kiriting.") |
| return |
| |
| if username.startswith("http"): |
| # Agar naqd link tashlasa |
| qr_data = username |
| else: |
| data = await state.get_data() |
| p_format = data["profile_platform"] |
| qr_data = format_profile(p_format, username) |
| |
| await generate_and_send(message, qr_data, "profile", state, bot) |
| """ |
|
|
| content = content + "\n\n" + handlers_code |
|
|
| with open('handlers/generate.py', 'w', encoding='utf-8') as f: |
| f.write(content) |
| print("File updated!") |
|
|