• Ilova (dastur kodi)
  • O‘zbekiston respublikasi raqamli texnologiyalar vazirligi toshkent axborot texnologiyalari universiteti




    Download 1.57 Mb.
    bet8/10
    Sana14.12.2023
    Hajmi1.57 Mb.
    #118407
    1   2   3   4   5   6   7   8   9   10
    Bog'liq
    Individual loyiha
    6-amaliy topshiriqPedogilka, kompyuter tarmoq 1, 4-topshiriq
    Foydalanilgan adabiyotlar.

    1. Python Essential Reference, David Beazley

    2. An Introduction to Python, Guido van Rossum, and Fred L. Drake, Jr.

    3. “Python-Telegram-Bot” qo‘llanma

    4. “A Byte of Python” Swaroop Chitlur

    5. “Pythonista Telegram Bot Development” GitHub

    6. http://google.com qidiruv tizimi

    7. http://w3schools web sayti

    8. https://docs.aiogram.dev web sayti


    Ilova (dastur kodi)
    from aiogram import types
    from aiogram.dispatcher import FSMContext
    from aiogram.dispatcher.filters import Text
    from aiogram.types import ReplyKeyboardRemove, CallbackQuery

    from data.texts import select_service, services, see_prices, send_message_admin, send_name_text, send_surname_text, \
    send_phone_text, resend_name_text, resend_phone_text, change_info, sended_message_admin
    from keyboards.default.menu_keyboard import menu_text, main_menu_keyboard, main_menu_list, menu, next_text
    from keyboards.inline.inline_keyboard import services_func, price_list, more, change, languages
    from loader import dp, db
    from states.MyState import MyState


    @dp.message_handler(text=menu_text[0])
    async def menu1(message: types.Message):
    """Xizmat turini tanlash"""
    user = dict(await db.select_user(telegram_id=message.from_user.id))
    await message.answer(select_service[user['lang']], reply_markup=ReplyKeyboardRemove())
    await message.answer(services[user['lang']], reply_markup=await services_func(user['lang']))


    @dp.callback_query_handler(text='back_services_list')
    async def service_func(call: CallbackQuery):
    """Xizmat turini tanlash"""
    await call.message.delete()
    user = dict(await db.select_user(telegram_id=call.from_user.id))
    await call.message.answer(select_service[user['lang']], reply_markup=ReplyKeyboardRemove())
    await call.message.answer(services[user['lang']], reply_markup=await services_func(user['lang']))


    @dp.callback_query_handler(Text(startswith='service:'))
    async def service_func(call: CallbackQuery):
    await call.message.delete()
    service_id = int(call.data.split(':')[1])
    user = dict(await db.select_user(telegram_id=call.from_user.id))
    name = 'name_uz' if user['lang'] == 'uz' else 'name_ru'
    service = dict(await db.select_service(id=service_id))
    print(service['price_image'])
    await call.message.answer(await see_prices(user['lang'], service[name], service['price_image']),
    reply_markup=await price_list(user['lang'], service_id))


    @dp.callback_query_handler(Text(startswith='price_list:'))
    async def service_func(call: CallbackQuery):
    await call.message.delete()
    service_id = int(call.data.split(':')[1])
    user = dict(await db.select_user(telegram_id=call.from_user.id))
    service = dict(await db.select_service(id=service_id))
    photo = service['price_image']
    name = 'name_uz' if user['lang'] == 'uz' else 'name_ru'
    await call.message.answer(f"{service[name]}",
    reply_markup=await more(user['lang'], service_id))


    @dp.callback_query_handler(text='more')
    async def service_func(call: CallbackQuery):
    user = await db.select_user1(telegram_id=call.from_user.id)
    user2 = await db.select_user(telegram_id=call.from_user.id)
    if user:
    await call.answer(sended_message_admin[user2['lang']])
    else:
    await db.add_user(user2['name'], user2['fullname'], user2['phone'], user2['username'],

    Download 1.57 Mb.
    1   2   3   4   5   6   7   8   9   10




    Download 1.57 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    O‘zbekiston respublikasi raqamli texnologiyalar vazirligi toshkent axborot texnologiyalari universiteti

    Download 1.57 Mb.