async def enter_summary(message: Message, state: FSMContext): summary = message.text async with state.proxy() as userevent: userevent["summary"] = summary await message.answer( text="Введите дату начала события в формате гггг-мм-дд:", reply_markup=hide_menu()) await States.ENTER_DATESTART_STATE.set()
async def enter_date_end(message: Message, state: FSMContext): try: date_end = time.strptime(message.text, '%Y-%m-%d') date_end = message.text async with state.proxy() as userevent: userevent["date_end"] = date_end async with state.proxy() as userevent: userevent_global = userevent await message.answer( text="Введите время окончания события в формате чч:мм :", reply_markup=hide_menu()) await States.ENTER_TIMEEND_STATE.set() except ValueError: await message.answer(text="Некорректный формат даты! Введите еще раз:")
async def enter_time_end(message: Message, state: FSMContext): try: time_end = time.strptime(message.text, '%H:%M') time_end = message.text async with state.proxy() as userevent: userevent["time_end"] = time_end async with state.proxy() as userevent: userevent_global = userevent async with state.proxy() as userevent: userevent["end_date"] = str(userevent_global["date_end"] + 'T' + userevent_global["time_end"] + ':00+03:00') await message.answer(text="Введите описание события:", reply_markup=hide_menu()) await States.ENTER_DESCRIPTION_STATE.set() except ValueError: await message.answer(text="Некорректный формат времени! Введите еще раз:")
async def start_conversation(message: Message): """ При первом запуске бота :param message: :return: """ if Worker.check_worker_exists(message.from_user): await States.COMMAND_STATE.set() await general_menu(message) else: await States.ENTER_EMAIL_STATE.set() await message.answer( text= "Давайте пройдем простую процедуру регистрации. Это займет не более двух минут" ) await message.answer(text="Введите ваш E-mail:", reply_markup=hide_menu())
async def enter_time_start(message: Message, state: FSMContext): try: time_start = time.strptime(message.text, '%H:%M') time_start = message.text async with state.proxy() as userevent: userevent["time_start"] = time_start async with state.proxy() as userevent: userevent_global = userevent async with state.proxy() as userevent: userevent["start_date"] = str(userevent_global["date_start"] + 'T' + userevent_global["time_start"] + ':00+03:00') await message.answer( text="Введите дату окончания события в формате гггг-мм-дд:", reply_markup=hide_menu()) await States.ENTER_DATEEND_STATE.set() except ValueError: await message.answer( text="Некорректный формат времени! Введите еще раз:")
async def enter_email(message: Message, state: FSMContext): email = message.text async with state.proxy() as userdata: userdata["email"] = email global userdata_global async with state.proxy() as userdata: userdata_global = userdata # await message.answer(text="Введите вашу должность:", reply_markup=hide_menu()) await message.answer(text="Ожидайте подверждения вашим работодателем", reply_markup=hide_menu()) # await States.ENTER_POST_STATE.set() connection = Worker() try: connection.add_worker(message.from_user, userdata_global["email"]) # except PostNotFound as post_err: # text_message = "Такой должности не существует.\nПопробуйте ввести снова:" # print(post_err) # markup = hide_menu() except IdNotUnique as unique_err: print(unique_err) await bot.send_message(chat_id=admin_id, text="Поступили новые заявки на регистрацию:", reply_markup=check_new_users_menu())
async def create_event(message: Message): await message.answer(text="Введите название события:", reply_markup=hide_menu()) await States.ENTER_SUMMARY_STATE.set()