if self.MESSAGE["text"].lower() == "!пара": try: schedule = json.loads( readfile(self.path + "schedule.json") ) current_time = datetime.datetime.now() current_week = current_time.isocalendar()[1] % 2 current_day = current_time.weekday() current_seconds = (current_time.hour + 1) * 3600 + current_time.minute * 60 + current_time.second print(f"[DEBUG] Current day is {type(current_day)}({current_day})") if current_day > 4 or current_day < 0: next_week = int(not bool(current_week)) day = -1 next_pair = None pair_found = False for i in schedule[next_week]: if not pair_found: day += 1 for j in schedule[next_week][day]: next_pair = schedule[next_week][day][j] pair_found = True break self.RESPONCE = f"Сьогодні вихідний, тому пар немає)\n"\ f"Наступна пара - {next_pair['subject']} ({next_pair['lector']}) о {self.reverse_timetable[int(j)]} у {self.days_rod[day]}\n"\ f"Посилання (якщо воно чомусь треба): {next_pair['link']}" else: for i in self.timetable: if current_seconds < i: print("[DEBUG] Looking up a relevant pair...") try: relevant_pair = schedule[current_week][current_day][str(self.timetable[i])] self.RESPONCE = f"Актуальна пара: {relevant_pair['subject']} ({relevant_pair['lector']}), початок о {self.reverse_timetable[self.timetable[i]]}\n"\ f"Посилання: {relevant_pair['link']}" break except Exception as e: print(f"[WARN] module: auto-schedule: exception {e} while looking up the pair") else: self.RESPONCE = "Сьогодні більше немає пар" except Exception as e: print(f"[WARN] module: auto-schedule: failed to process schedule.json ({e})")