async def ask_username(message: types.Message, state: FSMContext):
    user_data = await state.get_data()

    user_name = message.text
    user_phone = user_data["phone"]
    start_hour = int(user_data["hour"])
    end_hour = int(start_hour + 3)
    date = user_data["date"]
    res = DateHelper.get_formatted_date(date, start_hour)
    response = f'{Dialog.name_desc} {user_name}\n' \
               f'{Dialog.phone_desc} {user_phone}\n' \
               f'{Dialog.date_desc} {res}'
    await message.answer(response)
    await state.finish()
    await state.reset_state(with_data=True)

    user_id = message.chat.id
    client_added = db.add_client(user_id=user_id,
                                 phone=user_phone,
                                 creation_date=f"{datetime.now()}",
                                 registration_date=date,
                                 start=start_hour,
                                 end=end_hour,
                                 user_name=user_name,
                                 deposit=0)
    print(client_added)
    await message.answer(Dialog.thanks_for_registration)
    for admin in admins:
        await dp.bot.send_message(
            chat_id=admin, text=f"{user_name} только что записался на сеанс.")
Ejemplo n.º 2
0
def get_description(user_id: int):
    client = db.get_client(user_id)
    date = DateHelper.get_formatted_date(client[3],
                                         client[4]) + f"-{client[5]}:00"
    phone = client[1]
    name = client[6]
    deposit = "Нет" if client[7] == 0 else "Да"
    res = f"Имя: {name}\nТелефон: {phone}\nДата записи: {date}\nЗалог внесен: {deposit}"
    return res
async def open_calendar(message: types.Message):
    user_id = message.chat.id
    client_has_appointment = db.check_if_user_has_appointment(user_id)
    if client_has_appointment:
        await message.answer(Dialog.already_have_appointment)
        client = db.get_client(user_id)
        if client:
            registered_date = client[3]
            session_start = client[4]
            res = DateHelper.get_formatted_date(registered_date, session_start)
            await message.answer(Dialog.date_desc + " " + res)
    else:
        await message.answer(Dialog.opening_calendar,
                             reply_markup=ReplyKeyboardRemove())
        await message.answer(Dialog.pick_date, reply_markup=create_calendar())
        await RegistrationState.picking_date.set()