From 8735d2467b195a8918ff21237e2e93f82a1f1052 Mon Sep 17 00:00:00 2001 From: nex <53234499+EEKIM10@users.noreply.github.com> Date: Sun, 30 Oct 2022 16:34:26 +0000 Subject: [PATCH] Update timetable message function --- cogs/timetable.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/cogs/timetable.py b/cogs/timetable.py index 8d96760..ef81c48 100644 --- a/cogs/timetable.py +++ b/cogs/timetable.py @@ -31,6 +31,7 @@ class TimeTableCog(commands.Cog): for name, dates in self.timetable["breaks"].items(): start_date = datetime.strptime(dates["start"], "%d/%m/%Y") end_date = datetime.strptime(dates["end"], "%d/%m/%Y") + # noinspection PyChainedComparisons if date.timestamp() <= end_date.timestamp() and date.timestamp() >= start_date.timestamp(): return {"name": name, "start": start_date, "end": end_date} @@ -109,9 +110,8 @@ class TimeTableCog(commands.Cog): ): date = date or datetime.now() _break = self.are_on_break(date) - if _break: - next_lesson = self.next_lesson(_break["end"] + timedelta(days=1, hours=7)) - next_lesson = next_lesson or {"name": "Unknown", "tutor": "Unknown", "room": "Unknown"} + if _break is not None: + next_lesson = self.absolute_next_lesson(date) text = ( "[tt] On break {!r} from {} until {}. Break ends {}, and the first lesson back is " "{lesson[name]!r} with {lesson[tutor]} in {lesson[room]}.".format( @@ -127,13 +127,7 @@ class TimeTableCog(commands.Cog): if not lesson: next_lesson = self.next_lesson(date) if not next_lesson: - next_lesson = await asyncio.to_thread(self.absolute_next_lesson, new_method=True) - next_lesson = next_lesson or { - "name": "unknown", - "tutor": "unknown", - "room": "unknown", - "start_datetime": datetime.max, - } + next_lesson = self.absolute_next_lesson() text = ( "[tt] No more lessons today!\n" f"[tt] Next Lesson: {next_lesson['name']!r} with {next_lesson['tutor']} in "