Example #1
0
async def showCardItem(message: types.Message, state: FSMContext):
    if 'Назад' in message.text:
        await deleteMessages(message.message_id, message.chat.id, state)
        await message.answer('Выберите категорию',
                             reply_markup=mainYapMarkup(),
                             disable_notification=True)
        await Yap.yapMainMenu.set()
        return
    txt = message.text.split('|')[0].lower().strip()
    data = await state.get_data('card')
    card: Card = data['card']
    numb = card.isInCard(txt)
    if numb != -1:
        result = yap_db.getFromDB('items',
                                  f'name, weight, price, position',
                                  where=f"id='{card.items[numb].sqlId}'",
                                  orderBy='ORDER BY POSITION')
        if result.__len__() == 1:
            await sendNewPhoto(message, state, result[0][3], True)
            await message.answer(
                'Дли изменения количества нажмите + или - на клавиатуре выше',
                reply_markup=types.ReplyKeyboardRemove())
            await Yap.showPhotos.set()
    else:
        await message.answer('Выберите блюдо из корзины')
Example #2
0
async def goBack(message: types.Message, state: FSMContext):
    user = User(message.from_user.id)
    currentState = await state.get_state()
    if currentState is None:
        await message.answer('Перехожу в главное меню', reply_markup=mainMarkup(), disable_notification=True)
        return
    currentState = currentState.split(':')[1]
    await message.delete()
    if currentState in [
        'otherCurrency',
        'changeCurrencyFrom',
        'changeCurrencyFrom',
        'selectCurrencyFrom'
    ]:
        await message.answer('Выберите валюту', reply_markup=mainCurrencyMarkup(user), disable_notification=True)
        await CurrencyState.mainMenu.set()
    elif currentState in [
        'mainMenu',
        'settingsMenu',
        'searchState',
        'weatherMenu',
        'yapMainMenu',
        'bookMenu'
    ]:
        await message.answer('Окей. Перехожу в главное меню', reply_markup=mainMarkup(), disable_notification=True)
        await state.finish()

    elif currentState in ['subMenu', 'showPhotos', 'card']:
        await deleteMessages(message.message_id, message.chat.id, state)
        await message.answer('Выберите категорию', reply_markup=mainYapMarkup(), disable_notification=True)
        await Yap.yapMainMenu.set()
Example #3
0
async def showItem(message: types.Message, state: FSMContext):
    await message.delete()
    data = await state.get_data()
    if 'Назад' in message.text:
        await deleteMessages(message.message_id, message.chat.id, state)
        await message.answer('Выберите категорию',
                             reply_markup=mainYapMarkup(),
                             disable_notification=True)
        await Yap.yapMainMenu.set()
        return
    txt = message.text.split('|')[0].lower().strip()
    if data['type'] in ['rolly', 'royal', 'sety']:
        quantity = ', quantity'
    else:
        quantity = ''
    result = yap_db.getFromDB('items',
                              f'name, weight, price, position{quantity}',
                              where=f"name='{txt}' and type='{data['type']}'",
                              orderBy='ORDER BY POSITION')
    if result.__len__() == 0:
        result = yap_db.getFromDB(
            'items',
            f'name, weight, price, position{quantity}',
            where=f"name like '%{txt}%' and type='{data['type']}'",
            orderBy='ORDER BY POSITION')
    if result.__len__() == 0:
        await message.answer('Не могу найти блюдо с таким названием 😔')
    elif result.__len__() == 1:
        await sendNewPhoto(message, state, result[0][3], True)
    else:
        await dp.bot.delete_message(message.chat.id, message.message_id - 1)
        await message.answer('Выберите блюдо',
                             reply_markup=allItemsMenu(result, quantity),
                             disable_notification=True)
Example #4
0
async def openSettingsMenu(message: types.Message, state: FSMContext):
    await message.delete()
    await message.answer("Выберите категорию",
                         reply_markup=mainYapMarkup(),
                         disable_notification=True)
    await Yap.yapMainMenu.set()
    data = {
        'current': 1,
        'type': '',
        'card': Card(),
        'productType': message.text,
        'order': 'asc',
        'startId': message.message_id
    }
    await state.set_data(data)
Example #5
0
async def changePhoto(call: CallbackQuery, state: FSMContext):
    await yaposhka_test.deleteMessages(call.message.message_id + 1, call.message.chat.id, state)
    await call.message.answer("Выберите категорию", reply_markup=mainYapMarkup())
    await Yap.yapMainMenu.set()