async def tip_handler(ans: Message):
    """Команда Помощь"""
    chat_id = ans.from_id
    user = storage.get_vk_user(chat_id=chat_id)
    if not user:
        user = []
    if len(user) == 6:
        await commands.help(ans=ans)
    else:
        await ans.answer('Для начала пройдите регистрацию 😉')
    statistics.add(action='help', storage=storage, tz=TZ_IRKUTSK)
async def show_map_handler(ans: Message):
    """Команда Карта"""
    chat_id = ans.from_id
    user = storage.get_vk_user(chat_id=chat_id)
    if not user:
        user = []
    if len(user) == 6:
        await commands.show_map(ans=ans, photo_vk_name=map_image)
    else:
        await ans.answer('Для начала пройдите регистрацию 😉')

    statistics.add(action='map', storage=storage, tz=TZ_IRKUTSK)
def registration(bot, message, storage, tz):
    """Команда бота Регистрация"""
    chat_id = message.chat.id
    storage.delete_user_or_userdata(chat_id=chat_id)
    bot.send_message(
        chat_id=chat_id,
        text='Пройдите повторную регистрацию😉\n'
        'Выберите институт',
        reply_markup=keyboards.make_inline_keyboard_choose_institute(
            storage.get_institutes()))

    statistics.add(action='reg', storage=storage, tz=tz)
def about(bot, message, storage, tz):
    chat_id = message.chat.id
    bot.send_message(
        chat_id=chat_id,
        parse_mode='HTML',
        text='<b>О боте:\n</b>'
        'Smart schedule IRNITU bot - это чат бот для просмотра расписания занятий в '
        'Иркутском национальном исследовательском техническом университете\n\n'
        '<b>Благодаря боту можно:\n</b>'
        '- Узнать актуальное расписание\n'
        '- Нажатием одной кнопки увидеть информацию о ближайшей паре\n'
        '- Настроить гибкие уведомления с информацией из расписания, '
        'которые будут приходить за определённое время до начала занятия')

    statistics.add(action='about', storage=storage, tz=tz)
def help_info(bot, message, storage, tz):
    chat_id = message.chat.id
    bot.send_message(
        chat_id=chat_id,
        text=
        'Список доступных Вам команд, для использования просто напишите их в чат😉:\n'
        '/start – запустить диалог с ботом сначала\n'
        '/reg – пройти регистрацию заново\n'
        '/map – карта корпусов ИРНИТУ\n'
        '/about – краткая информация о боте\n'
        '/authors – мои создатели\n'
        '/tip – подсказка\n'
        '/help – список доступных команд\n')

    statistics.add(action='help', storage=storage, tz=tz)
def authors(bot, message, storage, tz):
    """Команда бота Авторы"""
    chat_id = message.chat.id
    bot.send_message(
        chat_id=chat_id,
        parse_mode='HTML',
        text='<b>Авторы проекта:\n</b>'
        '- Алексей @bolanebyla\n'
        '- Султан @ace_sultan\n'
        '- Александр @alexandrshen\n'
        '- Владислав @TixoNNNAN\n'
        '- Кирилл @ADAMYORT\n\n'
        'По всем вопросом и предложениям пишите нам в личные сообщения. '
        'Будем рады 😉\n')
    statistics.add(action='authors', storage=storage, tz=tz)
def text(message):
    chat_id = message.chat.id
    data = message.text
    user = storage.get_user(chat_id=chat_id)
    logger.info(f'Message data: {data}')

    if user:
        bot.send_message(chat_id, text='Я вас не понимаю 😞\n'
                                       'Для вызова подсказки используйте команду [Подсказка]\n'
                                       'Для просмотра списка команд используйте команду [Помощь]\n',
                         reply_markup=make_keyboard_start_menu())
    else:
        bot.send_message(chat_id, text='Я вас не понимаю 😞\n'
                                       'Похоже Вы не завершили регистрацию\n'
                                       'Чтобы использовать меня, завершите ее🙏')

    statistics.add(action='bullshit', storage=storage, tz=TZ_IRKUTSK)
def start(bot, message, storage, tz):
    """Команда бота Начать"""
    chat_id = message.chat.id

    # Проверяем есть пользователь в базе данных
    if storage.get_user(chat_id):
        storage.delete_user_or_userdata(
            chat_id)  # Удаляем пользвателя из базы данных

    bot.send_message(
        chat_id=chat_id,
        text='Для начала пройдите небольшую регистрацию😉\n'
        'Выберите институт',
        reply_markup=keyboards.make_inline_keyboard_choose_institute(
            storage.get_institutes()))

    statistics.add(action='start', storage=storage, tz=tz)
def tip(bot, message, storage, tz):
    """Команда бота Подсказка"""
    chat_id = message.chat.id
    bot.send_message(
        chat_id=chat_id,
        parse_mode='HTML',
        text=
        'Здравствуйте! Раз Вы вызвали Подсказку еще раз, значит дело серьезное.😬\n\n'
        'Напомню Вам основные советы по использованию бота:\n'
        '⏭Используйте кнопки, так я буду Вас лучше понимать!\n\n'
        '🌄Подгружайте расписание утром и оно будет в нашем чате до скончания времен!\n\n'
        '📃Чтобы просмотреть список доступных команд и кнопок, напишите в чате [Помощь]\n\n'
        '🆘Чтобы вызвать эту подсказку снова, напиши в чат [Подсказка] \n\n'
        'Если Вы столкнулись с технической проблемой, то Вы можете:\n'
        '- обратиться за помощью в официальную группу ВКонтакте [https://vk.com/smartschedule]\n'
        '- написать одному из моих создателей (команда Авторы)🤭\n')
    statistics.add(action='tip', storage=storage, tz=tz)
예제 #10
0
async def processing_main_buttons(ans: Message, storage, tz):
    chat_id = ans.from_id
    message = ans.text
    user = storage.get_vk_user(chat_id)

    if 'Основное меню' in message and user.get('group'):
        await ans.answer('Основное меню',
                         keyboard=keyboards.make_keyboard_start_menu())
        statistics.add(action='Основное меню', storage=storage, tz=tz)

    elif '<==Назад' == message and user.get('group'):
        await ans.answer('Основное меню',
                         keyboard=keyboards.make_keyboard_start_menu())

    elif 'Другое ⚡' == message and user.get('group'):
        await ans.answer('Другое', keyboard=keyboards.make_keyboard_extra())
        statistics.add(action='Другое', storage=storage, tz=tz)
        return

    elif 'Поиск 🔎' == message and user.get('group'):
        await ans.answer('Выберите, что будем искать',
                         keyboard=keyboards.make_keyboard_search())
예제 #11
0
def processing_main_buttons(bot, message, storage, tz):
    chat_id = message.chat.id
    data = message.text
    user = storage.get_user(chat_id=chat_id)

    if 'Основное меню' in data and user:
        bot.send_message(chat_id, text='Основное меню', reply_markup=keyboards.make_keyboard_start_menu())

        statistics.add(action='Основное меню', storage=storage, tz=tz)

    elif 'Список команд' in data and user:
        bot.send_message(chat_id, text='Список команд:\n'
                                       'Авторы - список авторов \n'
                                       'Регистрация- повторная регистрация\n'
                                       'Карта - карта университета', reply_markup=keyboards.make_keyboard_commands())

        statistics.add(action='Список команд', storage=storage, tz=tz)

    elif 'Другое ⚡' in data and user:
        bot.send_message(chat_id, text='Другое', reply_markup=keyboards.make_keyboard_extra())

        statistics.add(action='Другое', storage=storage, tz=tz)
async def start_student_reg(ans: Message, storage, tz):
    chat_id = ans.from_id
    message_inst = ans.text
    message = ans.text
    user = storage.get_vk_user(chat_id)

    # Сохраняет в месседж полное название универ для корректного сравнения
    institutes = name_institutes(storage.get_institutes())
    for institute in institutes:
        if len(message_inst) > 5:
            if message_inst[:-5] in institute:
                message_inst = institute

    # Если пользователя нет в базе данных
    if not user and ans.payload:
        institutes = name_institutes(storage.get_institutes())
        # Смотрим выбрал ли пользователь институт
        if message_inst in institutes:
            # Если да, то записываем в бд
            storage.save_or_update_vk_user(chat_id=chat_id, institute=message_inst)
            await ans.answer(f'Вы выбрали: {message_inst}\n')
            await ans.answer('Выберите курс.',
                             keyboard=keyboards.make_keyboard_choose_course_vk(storage.get_courses(message_inst)))
        else:
            await commands.start(ans=ans, chat_id=chat_id, storage=storage)

    # Если нажал кнопку Назад к институтам
    elif message == "Назад к институтам" and not 'course' in user.keys():
        await ans.answer('Выберите институт.', keyboard=keyboards.make_keyboard_institutes(storage.get_institutes()))
        storage.delete_vk_user_or_userdata(chat_id=chat_id)
        return

    # Если нажал кнопку Назад к курсам
    elif message == "Назад к курсам" and not 'group' in user.keys():

        await ans.answer('Выберите курс.', keyboard=keyboards.make_keyboard_choose_course_vk(
            storage.get_courses(storage.get_vk_user(chat_id=chat_id)['institute'])))
        storage.delete_vk_user_or_userdata(chat_id=chat_id, delete_only_course=True)
        return

    # Регистрация после выбора института
    elif ans.payload and not 'course' in user.keys():
        institute = user['institute']
        course = storage.get_courses(institute)
        # Если нажал кнопку курса
        if message in name_courses(course):
            # Записываем в базу данных выбранный курс
            storage.save_or_update_vk_user(chat_id=chat_id, course=message)
            groups = storage.get_groups(institute=institute, course=message)
            groups = name_groups(groups)
            await ans.answer(f'Вы выбрали: {message}\n')
            await ans.answer('Выберите группу.', keyboard=keyboards.make_keyboard_choose_group_vk(groups))
            return
        else:
            await ans.answer('Не огорчай нас, мы же не просто так старались над клавиатурой 😼👇🏻',
                             keyboard=keyboards.make_keyboard_choose_course_vk(
                                 storage.get_courses(storage.get_vk_user(chat_id=chat_id)['institute']))
                             )
        return

    # Регистрация после выбора курса
    elif ans.payload and not 'group' in user.keys():
        institute = user['institute']
        course = user['course']
        groups = storage.get_groups(institute=institute, course=course)
        groups = name_groups(groups)
        # Если нажал кнопку группы
        if message in groups:
            # Записываем в базу данных выбранную группу
            storage.save_or_update_vk_user(chat_id=chat_id, group=message)
            await ans.answer("Приветствую Вас, Пользователь! Вы успешно зарегистрировались!😊 \n\n"
                             "Я чат-бот для просмотра расписания занятий в Иркутском Политехе.🤖\n\n"
                             "С помощью меня можно не только смотреть свое расписание на день или неделю, но и осуществлять поиск расписания по группам, аудиториям и преподавателям (кнопка [Поиск]).\n"
                             "А еще можно настроить уведомления о парах (в разделе [Другое] кнопка [Напоминания]).\n\n"
                             "Следующие советы помогут раскрыть мой функционал на 💯 процентов:\n"
                             "⏭Используйте кнопки, так я буду Вас лучше понимать!\n\n"
                             "🌄Подгружайте расписание утром и оно будет в нашем чате до скончания времен!\n\n"
                             "📃Чтобы просмотреть список доступных команд и кнопок, напишите в чате [Помощь]\n\n"
                             "🆘Чтобы вызвать эту подсказку снова, напиши в чат [Подсказка] \n\n"
                             "Надеюсь, что Вам будет удобно меня использовать. Для того чтобы пройти регистрацию повторно, напишите сообщение [Регистрация]\n\n"
                             "Если Вы столкнетесь с технической проблемой, то Вы можете:\n"
                             "- обратиться за помощью в официальную группу ВКонтакте [https://vk.com/smartschedule]\n"
                             "- написать одному из моих создателей (команда Авторы)🤭\n",
                             keyboard=keyboards.make_keyboard_start_menu())
        else:
            if message == "Далее":
                await ans.answer('Выберите группу.', keyboard=keyboards.make_keyboard_choose_group_vk_page_2(groups))
            elif message == "Назад":
                await ans.answer('Выберите группу.', keyboard=keyboards.make_keyboard_choose_group_vk(groups))
            else:
                await ans.answer('Я очень сомневаюсь, что твоей группы нет в списке ниже 😉',
                                 keyboard=keyboards.make_keyboard_choose_group_vk(groups))
        return

    elif 'Далее' in message:
        await ans.answer('Далее', keyboard=keyboards.make_keyboard_choose_group_vk_page_2())

    else:
        if not user:
            user = []
        try:
            if len(user) == 6:
                await ans.answer('Такому ещё не научили 😇:\n'
                                 'Для вызова подсказки используйте команду [Подсказка]\n'
                                 'Для просмотра списка команд используйте команду [Помощь]\n')
        finally:
            if len(user) != 6:
                await ans.answer('Пожалуйста, закончите регистрацию 😇', keyboard = keyboards.start_button())

        statistics.add(action='bullshit', storage=storage, tz=tz)
async def reminder_settings(ans: Message, storage, tz):
    chat_id = ans.from_id
    message = ans.text
    user = storage.get_vk_user(chat_id)

    time = user['notifications']
    if not time:
        time = 0

    # Проверяем статус напоминания
    notifications_status = get_notifications_status(time)
    if isinstance(notifications_status, APIError):
        await schedule_processing.sending_service_is_not_available(ans=ans)
        return

    if message == 'Напоминание 📣' and user.get('group'):
        await ans.answer(
            f'{notifications_status}',
            keyboard=keyboards.make_inline_keyboard_notifications())
        statistics.add(action='Напоминание', storage=storage, tz=tz)

    elif message == 'Настройки ⚙' and user.get('group'):
        await ans.answer(
            'Настройка напоминаний ⚙\n\n'
            'Укажите за сколько минут до начала пары должно приходить сообщение',
            keyboard=keyboards.make_inline_keyboard_set_notifications(time))
        statistics.add(action='Настройки', storage=storage, tz=tz)

    elif '-' == message:
        if time == 0:
            await ans.answer(
                'Хочешь уйти в минус?',
                keyboard=keyboards.make_inline_keyboard_set_notifications(
                    time))
            return
        time -= 5
        # Отнимаем и проверяем на положительность
        if time <= 0:
            time = 0
        storage.save_or_update_vk_user(chat_id=chat_id, notifications=time)
        await ans.answer(
            'Минус 5 минут',
            keyboard=keyboards.make_inline_keyboard_set_notifications(time))
        return

    elif '+' == message:
        time += 5
        storage.save_or_update_vk_user(chat_id=chat_id, notifications=time)
        await ans.answer(
            'Плюс 5 минут',
            keyboard=keyboards.make_inline_keyboard_set_notifications(time))

    elif message == 'Сохранить':
        # Сохраняем статус в базу
        group = storage.get_vk_user(chat_id=chat_id)['group']

        if storage.get_vk_user(chat_id=chat_id)['course'] == "None":
            schedule = storage.get_schedule_prep(group=group)['schedule']
        else:
            schedule = storage.get_schedule(group=group)['schedule']
        if time > 0:
            reminders = calculating_reminder_times(schedule=schedule,
                                                   time=int(time))
        else:
            reminders = []
        storage.save_or_update_vk_user(chat_id=chat_id,
                                       notifications=time,
                                       reminders=reminders)

        await ans.answer(f'{get_notifications_status(time)}',
                         keyboard=keyboards.make_keyboard_start_menu())
예제 #14
0
async def registration_handler(ans: Message):
    """Команда Регистрация"""
    chat_id = ans.from_id
    await commands.registration(ans=ans, chat_id=chat_id, storage=storage)
    statistics.add(action='reg', storage=storage, tz=TZ_IRKUTSK)
예제 #15
0
async def start_message_handler(ans: Message):
    """Команда Начать"""
    chat_id = ans.from_id
    await commands.start(ans=ans, chat_id=chat_id, storage=storage)
    statistics.add(action='start', storage=storage, tz=TZ_IRKUTSK)
def show_map(bot, message, storage, tz):
    """Команда бота Карта"""
    chat_id = message.chat.id
    bot.send_photo(chat_id, (open('map.jpg', "rb")))
    statistics.add(action='map', storage=storage, tz=tz)
def get_schedule(bot, message, storage, tz):
    chat_id = message.chat.id
    data = message.text
    user = storage.get_user(chat_id=chat_id)

    if 'Расписание 🗓' == data and user.get('group'):
        bot.send_message(
            chat_id=chat_id,
            text='Выберите период\n',
            reply_markup=keyboards.make_keyboard_choose_schedule())
        statistics.add(action='Расписание', storage=storage, tz=tz)

    if ('На текущую неделю' == data
            or 'На следующую неделю' == data) and user.get('group'):
        # Если курс нуль, тогда это преподаватель
        if storage.get_user(chat_id=chat_id)['course'] != 'None':
            group = storage.get_user(chat_id=chat_id)['group']
            schedule = storage.get_schedule(group=group)
        elif storage.get_user(chat_id=chat_id)['course'] == 'None':
            group = storage.get_user(chat_id=chat_id)['group']
            schedule = storage.get_schedule_prep(group=group)
        if not schedule or schedule['schedule'] == []:
            bot.send_message(
                chat_id=chat_id,
                text='Расписание временно недоступно\nПопробуйте позже⏱')
            statistics.add(action=data, storage=storage, tz=tz)
            return

        schedule = schedule['schedule']
        week = find_week()

        # меняем неделю
        if data == 'На следующую неделю':
            week = 'odd' if week == 'even' else 'even'

        week_name = 'четная' if week == 'odd' else 'нечетная'

        if storage.get_user(chat_id=chat_id)['course'] != 'None':
            schedule_str = full_schedule_in_str(schedule, week=week)
        elif storage.get_user(chat_id=chat_id)['course'] == 'None':
            schedule_str = full_schedule_in_str_prep(schedule, week=week)

        # Проверяем, что расписание сформировалось
        if isinstance(schedule_str, APIError):
            schedule_processing.sending_schedule_is_not_available(
                bot=bot, chat_id=chat_id)
            return

        bot.send_message(chat_id=chat_id,
                         text=f'Расписание {group}\n'
                         f'Неделя: {week_name}',
                         reply_markup=keyboards.make_keyboard_start_menu())
        # Отправка расписания
        schedule_processing.sending_schedule(bot=bot,
                                             chat_id=chat_id,
                                             schedule_str=schedule_str)

        statistics.add(action=data, storage=storage, tz=tz)

    elif 'Расписание на сегодня 🍏' == data and user.get('group'):
        # Если курс нуль, тогда это преподаватель
        if storage.get_user(chat_id=chat_id)['course'] != 'None':
            group = storage.get_user(chat_id=chat_id)['group']
            schedule = storage.get_schedule(group=group)
        elif storage.get_user(chat_id=chat_id)['course'] == 'None':
            group = storage.get_user(chat_id=chat_id)['group']
            schedule = storage.get_schedule_prep(group=group)
        if not schedule:
            bot.send_message(chat_id=chat_id,
                             text='Расписание временно недоступно🚫😣\n'
                             'Попробуйте позже⏱',
                             reply_markup=keyboards.make_keyboard_start_menu())
            statistics.add(action='Расписание на сегодня',
                           storage=storage,
                           tz=tz)
            return
        schedule = schedule['schedule']
        week = find_week()
        # Если курс нуль, тогда это преподаватель
        if storage.get_user(chat_id=chat_id)['course'] != 'None':
            schedule_one_day = get_one_day_schedule_in_str(schedule=schedule,
                                                           week=week)
        elif storage.get_user(chat_id=chat_id)['course'] == 'None':
            schedule_one_day = get_one_day_schedule_in_str_prep(
                schedule=schedule, week=week)

        # Проверяем, что расписание сформировалось
        if isinstance(schedule_one_day, APIError):
            schedule_processing.sending_schedule_is_not_available(
                bot=bot, chat_id=chat_id)
            return

        if not schedule_one_day:
            bot.send_message(chat_id=chat_id, text='Сегодня пар нет 😎')
            return
        bot.send_message(chat_id=chat_id, text=f'{schedule_one_day}')
        statistics.add(action='Расписание на сегодня', storage=storage, tz=tz)

    elif 'Экзамены' in data and user.get('group'):
        # Если курс нуль, тогда это преподаватель

        if storage.get_user(chat_id=chat_id)['course'] != 'None':
            group = storage.get_user(chat_id=chat_id)['group']
            schedule = groups_exam(group=group)
        elif storage.get_user(chat_id=chat_id)['course'] == 'None':
            group = storage.get_user(chat_id=chat_id)['group']
            schedule = groups_exam(group=group)

        if not schedule:
            bot.send_message(chat_id=chat_id,
                             text='Расписание экзаменов отсутствует😇\n'
                             'Попробуйте позже⏱',
                             reply_markup=keyboards.make_keyboard_start_menu())
            statistics.add(action='Экзамены', storage=storage, tz=tz)
            return

        # schedule = schedule['schedule']

        if storage.get_user(chat_id=chat_id)['course'] != 'None':
            schedule_exams = schedule_view_exams(schedule=schedule)
        elif storage.get_user(chat_id=chat_id)['course'] == 'None':
            schedule_exams = schedule_view_exams(schedule=schedule)

        # Проверяем, что расписание сформировалось
        if isinstance(schedule_exams, APIError):
            schedule_processing.sending_schedule_is_not_available(
                bot=bot, chat_id=chat_id)

            return

        schedule_processing.sending_schedule(bot=bot,
                                             chat_id=chat_id,
                                             schedule_str=schedule_exams)

        statistics.add(action='Экзамены', storage=storage, tz=tz)

    elif 'Расписание на завтра 🍎' == data and user.get('group'):
        # Если курс нуль, тогда это преподаватель
        if storage.get_user(chat_id=chat_id)['course'] != 'None':
            group = storage.get_user(chat_id=chat_id)['group']
            schedule = storage.get_schedule(group=group)
        elif storage.get_user(chat_id=chat_id)['course'] == 'None':
            group = storage.get_user(chat_id=chat_id)['group']
            schedule = storage.get_schedule_prep(group=group)
        if not schedule:
            bot.send_message(chat_id=chat_id,
                             text='Расписание временно недоступно🚫😣\n'
                             'Попробуйте позже⏱',
                             reply_markup=keyboards.make_keyboard_start_menu())
            statistics.add(action='Расписание на завтра',
                           storage=storage,
                           tz=tz)
            return
        schedule = schedule['schedule']
        week = find_week()
        if datetime.today().isoweekday() == 7:
            if week == 'odd':
                week = 'even'
            elif week == 'even':
                week = 'odd'
            else:
                week = 'all'

        if storage.get_user(chat_id=chat_id)['course'] != 'None':
            schedule_next_day = get_next_day_schedule_in_str(schedule=schedule,
                                                             week=week)
        elif storage.get_user(chat_id=chat_id)['course'] == 'None':
            schedule_next_day = get_next_day_schedule_in_str_prep(
                schedule=schedule, week=week)

        # Проверяем, что расписание сформировалось
        if isinstance(schedule_next_day, APIError):
            schedule_processing.sending_schedule_is_not_available(
                bot=bot, chat_id=chat_id)
            return

        if not schedule_next_day:
            bot.send_message(chat_id=chat_id, text='Завтра пар нет 😎')
            return
        bot.send_message(chat_id=chat_id, text=f'{schedule_next_day}')
        statistics.add(action='Расписание на завтра', storage=storage, tz=tz)

    elif 'Ближайшая пара ⏱' in data and user.get('group'):
        bot.send_message(chat_id=chat_id,
                         text='Ближайшая пара',
                         reply_markup=keyboards.make_keyboard_nearlesson())
        statistics.add(action='Ближайшая пара', storage=storage, tz=tz)
        return

    elif 'Текущая' in data and user.get('group'):
        if storage.get_user(chat_id=chat_id)['course'] != 'None':
            group = storage.get_user(chat_id=chat_id)['group']
            schedule = storage.get_schedule(group=group)
        elif storage.get_user(chat_id=chat_id)['course'] == 'None':
            group = storage.get_user(chat_id=chat_id)['group']
            schedule = storage.get_schedule_prep(group=group)
        if not schedule:
            bot.send_message(chat_id=chat_id,
                             text='Расписание временно недоступно🚫😣\n'
                             'Попробуйте позже⏱',
                             reply_markup=keyboards.make_keyboard_start_menu())
            statistics.add(action='Текущая', storage=storage, tz=tz)
            return
        schedule = schedule['schedule']
        week = find_week()

        now_lessons = get_now_lesson(schedule=schedule, week=week)

        # Проверяем, что расписание сформировалось
        if isinstance(now_lessons, APIError):
            schedule_processing.sending_schedule_is_not_available(
                bot=bot, chat_id=chat_id)
            return

        # если пар нет
        if not now_lessons:
            bot.send_message(chat_id=chat_id,
                             text='Сейчас пары нет, можете отдохнуть)',
                             reply_markup=keyboards.make_keyboard_start_menu())
            statistics.add(action='Текущая', storage=storage, tz=tz)
            return

        # Студент
        if storage.get_user(chat_id=chat_id)['course'] != 'None':
            now_lessons_str = get_now_lesson_in_str_stud(now_lessons)

        # Преподаватель
        elif storage.get_user(chat_id=chat_id)['course'] == 'None':
            now_lessons_str = get_now_lesson_in_str_prep(now_lessons)

        # Проверяем, что расписание сформировалось
        if isinstance(now_lessons_str, APIError):
            schedule_processing.sending_schedule_is_not_available(
                bot=bot, chat_id=chat_id)
            return

        bot.send_message(chat_id=chat_id,
                         text=f'🧠Текущая пара🧠\n'
                         f'{now_lessons_str}',
                         reply_markup=keyboards.make_keyboard_start_menu())

        statistics.add(action='Текущая', storage=storage, tz=tz)

    elif 'Следующая' in data and user.get('group'):
        if storage.get_user(chat_id=chat_id)['course'] != 'None':
            group = storage.get_user(chat_id=chat_id)['group']
            schedule = storage.get_schedule(group=group)
        elif storage.get_user(chat_id=chat_id)['course'] == 'None':
            group = storage.get_user(chat_id=chat_id)['group']
            schedule = storage.get_schedule_prep(group=group)
        if not schedule:
            bot.send_message(chat_id=chat_id,
                             text='Расписание временно недоступно🚫😣\n'
                             'Попробуйте позже⏱',
                             reply_markup=keyboards.make_keyboard_start_menu())
            statistics.add(action='Следующая', storage=storage, tz=tz)
            return
        schedule = schedule['schedule']
        week = find_week()

        near_lessons = get_near_lesson(schedule=schedule, week=week)

        # Проверяем, что расписание сформировалось
        if isinstance(near_lessons, APIError):
            schedule_processing.sending_schedule_is_not_available(
                bot=bot, chat_id=chat_id)
            return

        # если пар нет
        if not near_lessons:
            bot.send_message(chat_id=chat_id,
                             text='Сегодня больше пар нет 😎',
                             reply_markup=keyboards.make_keyboard_start_menu())
            statistics.add(action='Следующая', storage=storage, tz=tz)
            return

        # Студент
        if storage.get_user(chat_id=chat_id)['course'] != 'None':
            near_lessons_str = get_now_lesson_in_str_stud(near_lessons)

        # Преподаватель
        elif storage.get_user(chat_id=chat_id)['course'] == 'None':
            near_lessons_str = get_now_lesson_in_str_prep(near_lessons)

        # Проверяем, что расписание сформировалось
        if isinstance(near_lessons_str, APIError):
            schedule_processing.sending_schedule_is_not_available(
                bot=bot, chat_id=chat_id)
            return

        bot.send_message(chat_id=chat_id,
                         text=f'🧠Ближайшая пара🧠\n'
                         f'{near_lessons_str}',
                         reply_markup=keyboards.make_keyboard_start_menu())

        statistics.add(action='Следующая', storage=storage, tz=tz)