diff --git a/modules/auto-schedule/index.py b/modules/auto-schedule/index.py index 5b84dd4..e6c9dc5 100644 --- a/modules/auto-schedule/index.py +++ b/modules/auto-schedule/index.py @@ -5,10 +5,11 @@ if self.MESSAGE["text"].lower() == "!пара": current_time = datetime.datetime.now() current_week = current_time.isocalendar()[1] % 2 - current_day = current_time.weekday() - 1 + current_day = current_time.weekday() current_seconds = current_time.hour * 3600 + current_time.minute * 60 + current_time.second - - if current_day > 4: + + print("[DEBUG] Current day is {}({})".format(type(current_day), current_day)) + if current_day > 4 or current_day < 0: next_week = int(not bool(current_week)) day = -1 @@ -18,19 +19,19 @@ if self.MESSAGE["text"].lower() == "!пара": for i in schedule[next_week]: if not pair_found: day += 1 - for j in schedule[next_week][i]: - next_pair = schedule[next_week][i][j] + for j in schedule[next_week][day]: + next_pair = schedule[next_week][day][j] pair_found = True break - self.RESPONCE = "Сьогодні вихідний, тому пар немає)\nНаступна пара - {} ({}) у {}\nПосилання (якщо воно чомусь треба): {}".format(next_pair["subject"], next_pair["lector"], self.days[day], next_pair["link"]) + self.RESPONCE = "Сьогодні вихідний, тому пар немає)\nНаступна пара - {} ({}) о {} у {}\nПосилання (якщо воно чомусь треба): {}".format(next_pair["subject"], next_pair["lector"], self.reverse_timetable[int(j)], self.days_rod[day], 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 + 1][str(self.timetable[i])] - self.RESPONCE = "Актуальна пара: {} ({})\nПосилання: {}".format(relevant_pair["subject"], relevant_pair["lector"], relevant_pair["link"]) + relevant_pair = schedule[current_week][current_day][str(self.timetable[i])] + self.RESPONCE = "Актуальна пара: {} ({}), початок о {}\nПосилання: {}".format(relevant_pair["subject"], relevant_pair["lector"], self.reverse_timetable[self.timetable[i]], relevant_pair["link"]) break except Exception as e: print("[WARN] module: auto-schedule: exception {} while looking up the pair".format(e)) diff --git a/modules/auto-schedule/predefine.py b/modules/auto-schedule/predefine.py index 6264603..5c20175 100644 --- a/modules/auto-schedule/predefine.py +++ b/modules/auto-schedule/predefine.py @@ -1 +1,4 @@ self.timetable = {36300: 0, 43200: 1, 50100: 2, 57000: 3, 63900: 4, 72300: 5, 78900: 6} +self.days_rod = ["понеділок", "вівторок", "середу", "четвер", "п'ятницю"] + +self.reverse_timetable = ["8:30", "10:25", "12:20", "14:15", "16:10", "18:30", "20:20"]