コード例 #1
0
async def set_how_much_give_curr(call: types.CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()

    if call.data == 'exit':
        await call.message.answer(
            f'Создание заявки отменено. Испльзуйте меню\n===========',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()

        return

    currency = call.data
    request_data = await state.get_data()
    # получаем список уже имеющихся валют либо пустой список
    currencies__give = request_data['currencies__give']

    if currency not in currencies__give:
        currencies__give.append(currency)
        await state.update_data(currencies__give=currencies__give)

    if currency == 'rub':
        await state.update_data(sum_give_RUB=request_data['how_much_give'])
    if currency == 'usd':
        await state.update_data(sum_give_USD=request_data['how_much_give'])
    if currency == 'eur':
        await state.update_data(sum_give_EUR=request_data['how_much_give'])

    request_data = await state.get_data()
    result_data_to_show, keyboard = get_data_to_show(request_data)

    await call.message.answer(text=result_data_to_show, reply_markup=keyboard)
    await Request.type_end.set()
コード例 #2
0
async def set_date_from_text(message: types.Message, state: FSMContext):
    request_data = await state.get_data()
    await bot.delete_message(chat_id=message.chat.id,
                             message_id=request_data['_del_message'])
    await bot.delete_message(chat_id=message.chat.id,
                             message_id=message.message_id)

    match = re.fullmatch(r'\d\d\.\d\d', message.text)

    if match:
        await state.update_data(data_request=message.text)
        request_data = await state.get_data()

        result_data_to_show, keyboard = get_data_to_show(request_data)

        await message.answer(text=result_data_to_show, reply_markup=keyboard)
        await Request.type_end.set()
        # to final_step_ordering.py

    else:
        result = await message.answer(
            'Неправильный формат даты. Попробуйте еще раз ввести в формате чч.мм.\n(пример для 11 ноября: 11.11)'
        )
        await state.update_data(_del_message=result.message_id)
        await state.update_data(data_request='')
        await Request.data_request.set()
コード例 #3
0
ファイル: comment.py プロジェクト: itcosplay/cryptobot
async def comment_back(call: types.CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()

    request_data = await state.get_data()

    result_data_to_show, keyboard = get_data_to_show(request_data)

    await call.message.answer(text=result_data_to_show, reply_markup=keyboard)

    await Request.type_end.set()
    # to final_step_ordering.py

    return
コード例 #4
0
ファイル: comment.py プロジェクト: itcosplay/cryptobot
async def comment(message: types.Message, state: FSMContext):
    await state.update_data(comment=message.text)
    request_data = await state.get_data()

    await bot.delete_message(chat_id=message.chat.id,
                             message_id=request_data['_del_message'])
    await bot.delete_message(chat_id=message.chat.id,
                             message_id=message.message_id)

    result_data_to_show, keyboard = get_data_to_show(request_data)

    await message.answer(text=result_data_to_show, reply_markup=keyboard)

    await Request.type_end.set()
    # to final_step_ordering.py

    return
コード例 #5
0
async def set_date_from_buttons(call: types.CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()

    if call.data == 'set_current_date':
        current_date = datetime.today().strftime('%d.%m')
        await state.update_data(data_request=current_date)

    elif call.data == 'set_tomorrow_date':
        tomorrow_date = (datetime.now() + timedelta(days=1)).strftime("%d.%m")
        await state.update_data(data_request=tomorrow_date)

    elif call.data == 'set_after_tomorrow_date':
        after_tomorrow_date = (datetime.now() +
                               timedelta(days=2)).strftime("%d.%m")
        await state.update_data(data_request=after_tomorrow_date)

    elif call.data == 'exit':
        await call.message.answer(
            f'Создание заявки отменено\n========================',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()

        return

    else:  # call.data == 'enter_coustom_date'
        result = await call.message.answer('Введите дату в формате ЧЧ.ММ')
        await state.update_data(_del_message=result.message_id)
        await state.update_data(data_request='')
        await Request.data_request.set()

        return

    request_data = await state.get_data()
    result_data_to_show, keyboard = get_data_to_show(request_data)

    await call.message.answer(text=result_data_to_show, reply_markup=keyboard)
    await Request.type_end.set()
コード例 #6
0
ファイル: operation_type.py プロジェクト: itcosplay/cryptobot
async def set_operation_type(call: types.CallbackQuery, state: FSMContext):
    await call.answer()
    await call.message.delete()

    print(call.data)

    if call.data == 'get_in'  \
    or call.data == 'get_out' \
    or call.data == 'cash_in_ATM':
        await state.update_data(operation_type=call.data)

        currencies__how_much = []
        await state.update_data(currencies__how_much=currencies__how_much)

        result = await bot.send_message(chat_id=call.message.chat.id,
                                        text='введите сумму:')
        await state.update_data(_del_message=result.message_id)

        await Request.temp_sum_state.set()
        # to temp_sum_message_handler.py

    elif call.data == 'change':
        await state.update_data(operation_type=call.data)
        await state.update_data(currencies__recive=[])
        await state.update_data(currencies__give=[])
        await state.update_data(plus_minus='no')
        result = await call.message.answer(f'Сколько принимаем?')
        await state.update_data(_del_message=result.message_id)
        await Request.how_much_recive.set()
        # to how_much_recive.py

    elif call.data == 'cash_out_ATM':
        await state.update_data(operation_type='cash_out_ATM')
        # request_data = await state.get_data()

        # text, keyboard = get_data_to_show(request_data)

        # await call.message.answer(text, reply_markup=keyboard)
        currencies__how_much = []
        await state.update_data(currencies__how_much=currencies__how_much)

        result = await bot.send_message(chat_id=call.message.chat.id,
                                        text='введите сумму:')
        await state.update_data(_del_message=result.message_id)

        await Request.temp_sum_state.set()
        # to temp_sum_message_handler.py

        # await Request.type_end.set()
        # to final_step_ordering.py

    elif call.data == 'documents':
        await state.update_data(operation_type=call.data)

        request_data = await state.get_data()
        result_data_to_show, keyboard = get_data_to_show(request_data)

        await call.message.answer(text=result_data_to_show,
                                  reply_markup=keyboard)

        await Request.type_end.set()

        return

    else:
        await call.answer()
        await call.message.answer(
            f'Создание заявки отменено. Испльзуйте меню\n===========',
            reply_markup=create_kb_coustom_main_menu(call.message.chat.id))
        await state.finish()