def choose_way_search_by_teacher(message: Message): loggerDEBUG.debug(f'{message.from_user.username} :: "ПОИСК ПО ПРЕПОДАВАТЕЛЮ" :: start') dataBase.add_user(message.from_user.id, message.chat.id) dataBase.set_way(message.chat.id, States.TEACHER_SEARCH) dataBase.set_count_parameters(message.chat.id, 0) bot.send_message(message.chat.id, strings.ENTER_TEACHER, reply_markup=kb.determine_start_keyboard(dataBase.get_group(message.from_user.id))) loggerDEBUG.debug(f'{message.from_user.username} :: "ПОИСК ПО ПРЕПОДАВАТЕЛЮ" :: end')
def process_start_command(message: Message): dataBase.add_user(message.from_user.id, message.chat.id) dataBase.set_default_values(message.chat.id) bot.send_message(message.from_user.id, strings.MESSAGE_START, reply_markup=kb.determine_start_keyboard(dataBase.get_group(message.chat.id))) if message.from_user.username is None: loggerDEBUG.debug(f'/start None - {message.from_user.id}') else: loggerDEBUG.debug(f'/start {message.from_user.username} - {message.from_user.id}')
def group_one_parameter(chat_id, text): #main.loggerDEBUG.debug('поиск по группе (1)') if text == '1': date = datetime.datetime.today() group = jsonFormatter.search_by_group_and_date(dataBase.get_group(chat_id), jsonFormatter.week_to_string(date.weekday())) return group elif text == '2': date = datetime.datetime.today() + datetime.timedelta(days=1) group = jsonFormatter.search_by_group_and_date(dataBase.get_group(chat_id), jsonFormatter.week_to_string(date.weekday())) return group elif text == '7': group = jsonFormatter.search_by_group(dataBase.get_group(chat_id)) return group try: arrayData = data_to_array(text) date = datetime.datetime(int(arrayData[2]), int(arrayData[1]), int(arrayData[0])) group = jsonFormatter.search_by_group_and_date(dataBase.get_group(chat_id), jsonFormatter.week_to_string(date.weekday())) return group except: if dataBase.get_group(chat_id) == '': return strings.MESSAGE_ERROR_GROUP return strings.MESSAGE_ERROR_DATE
def teacher_one_parameter(chat_id, text): #main.loggerDEBUG.debug('поиск по преподавателю (1)') if text == '1': date = datetime.datetime.today() teacher = jsonFormatter.search_by_teacher_and_date(dataBase.get_teacher(chat_id), jsonFormatter.week_to_string(date.weekday())) return teacher elif text == '7': teacher = jsonFormatter.search_by_teacher(dataBase.get_teacher(chat_id)) return teacher else: try: arrayData = data_to_array(text) date = datetime.datetime(int(arrayData[2]), int(arrayData[1]), int(arrayData[0])) teacher = jsonFormatter.search_by_teacher_and_date(dataBase.get_teacher(chat_id), jsonFormatter.week_to_string(date.weekday())) return teacher except: if dataBase.get_group(chat_id) == '': return strings.MESSAGE_ERROR_TEACHER return strings.MESSAGE_ERROR_DATE
def text_reg_exp(user_id): if dataBase.get_group(user_id) == '': return None return f'{strings.SEARCH_BY_GROUP_FOR_TODAY_1}"{dataBase.get_group(user_id)}"'
def general_func(message: Message): # Обработка выбора пути с ReplyKeyboardMarkup way = dataBase.get_way(message.chat.id) countParam = dataBase.get_count_parameters(message.chat.id) # Работа с выводом информации-------------- if way == States.CURRENT_GROUP_SEARCH: stringOut = current_group_zero_parameters(message.chat.id, message.text) if stringOut is not None and stringOut != '': bot.send_message(message.chat.id, stringOut, reply_markup=kb.determine_start_keyboard(dataBase.get_group(message.chat.id))) else: bot.send_message(message.chat.id, strings.MESSAGE_ERROR_TEXT, reply_markup=kb.determine_start_keyboard(dataBase.get_group(message.chat.id))) dataBase.set_way(message.chat.id, States.MAIN) bot.send_message(message.chat.id, strings.MESSAGE_ONE_OF_LIST_COMMANDS, reply_markup=kb.determine_start_keyboard(dataBase.get_group(message.chat.id))) elif way == States.GROUP_SEARCH: if countParam == 0: stringOut = group_zero_parameters(message.chat.id, message.text) if stringOut == strings.MESSAGE_ERROR_GROUP or stringOut == strings.MESSAGE_ERROR_DATE: bot.send_message(message.chat.id, stringOut) if dataBase.get_group(message.chat.id) != '': bot.send_message(message.chat.id, f'\nТЕКУЩАЯ ГРУППА: {dataBase.get_group(message.chat.id)}') elif not stringOut == '' and stringOut is not None: bot.send_message(message.chat.id, stringOut) if dataBase.get_group(message.chat.id) != '': bot.send_message(message.chat.id, strings.MESSAGE_ONLY_DATE_GROUP + f'\nТЕКУЩАЯ ГРУППА: {dataBase.get_group(message.chat.id)}', reply_markup=kb.determine_start_keyboard(dataBase.get_group(message.chat.id))) dataBase.set_way(message.chat.id, States.MAIN) bot.send_message(message.chat.id, strings.MESSAGE_ONE_OF_LIST_COMMANDS, reply_markup=kb.determine_start_keyboard(dataBase.get_group(message.chat.id))) elif way == States.TEACHER_SEARCH: if countParam == 0: stringOut = teacher_zero_parameters(message.chat.id, message.text) if stringOut == strings.MESSAGE_ERROR_TEACHER or stringOut == strings.MESSAGE_ERROR_DATE: bot.send_message(message.chat.id, stringOut) if dataBase.get_teacher(message.chat.id) != '': bot.send_message(message.chat.id, f'\nТЕКУЩИЙ ПРЕПОДАВАТЕЛЬ: {dataBase.get_teacher(message.chat.id)}') elif not stringOut == '' and stringOut is not None: bot.send_message(message.chat.id, stringOut) if dataBase.get_teacher(message.chat.id) != '': bot.send_message(message.chat.id, strings.MESSAGE_ONLY_DATE_TEACHER + f'\nТЕКУЩИЙ ПРЕПОДАВАТЕЛЬ: {dataBase.get_teacher(message.chat.id)}') dataBase.set_way(message.chat.id, States.MAIN) bot.send_message(message.chat.id, strings.MESSAGE_ONE_OF_LIST_COMMANDS, reply_markup=kb.determine_start_keyboard(dataBase.get_group(message.chat.id))) elif way == States.FULL_TIMETABLE: if countParam == 0: bot.send_message(message.chat.id, strings.ENTER_COURSE_YEAR, reply_markup=kb.choiceCourse) dataBase.set_count_parameters(message.chat.id, dataBase.get_count_parameters(message.chat.id) + 1) elif countParam == 1: catch = catching_stupid_in_third(message.text) if not catch: strOut = all_time_table_one_parameters(message) if message.text == 'выйти': pass else: ln = len(strOut) if ln == 6: for i, sOut in enumerate(strOut): bot.send_message(message.chat.id, sOut) if not sOut == '' else print() else: bot.send_message(message.chat.id, strOut) else: #main.loggerDEBUG.debug('вывод всего расписания (null)') bot.send_message(message.chat.id, strings.MESSAGE_ERROR_ALL_TIME_TABLE) dataBase.set_way(message.chat.id, States.MAIN) bot.send_message(message.chat.id, strings.MESSAGE_ONE_OF_LIST_COMMANDS, reply_markup=kb.determine_start_keyboard(dataBase.get_group(message.chat.id))) elif way == States.BEST_ROOM: #main.loggerDEBUG.debug('когда свободна Б-209? (0)') if message.text == 'Сегодня': date = datetime.datetime.today() bot.send_message(message.chat.id, jsonFormatter.when_b209_is_free_by_date(jsonFormatter.week_to_string(date.weekday()))) elif message.text == 'На неделе': bot.send_message(message.chat.id, jsonFormatter.when_b209_is_free()) else: try: arrayData = data_to_array(message.text) date = datetime.datetime(int(arrayData[2]), int(arrayData[1]), int(arrayData[0])) strOut = jsonFormatter.when_b209_is_free_by_date(jsonFormatter.week_to_string(date.weekday())) bot.send_message(message.chat.id, strOut) except: bot.send_message(message.chat.id, strings.MESSAGE_ERROR_DATE) dataBase.set_way(message.chat.id, States.MAIN) bot.send_message(message.chat.id, strings.MESSAGE_ONE_OF_LIST_COMMANDS, reply_markup=kb.determine_start_keyboard(dataBase.get_group(message.chat.id))) else: bot.send_message(message.chat.id, strings.MESSAGE_ERROR_TEXT)