From d240c3c50f9fdb9ade44c521ed5165d1874a9917 Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Sun, 18 Apr 2021 23:24:46 +0200 Subject: [PATCH] Enable les again --- cogs/school.py | 32 ++++++++++++++------------------ data/remind.py | 2 +- functions/les.py | 5 +++-- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/cogs/school.py b/cogs/school.py index 270ab6d..64eae32 100644 --- a/cogs/school.py +++ b/cogs/school.py @@ -45,25 +45,21 @@ class School(commands.Cog): # @commands.check(checks.allowedChannels) @help.Category(category=Category.School) async def les(self, ctx, *day): - deadlines = ["SEL", "Webdevelopment", "Computerarchitectuur", "Wetenschappelijk Rekenen"] + parsed = les.parseArgs(day) - await ctx.send("'T is vakantie. Sort of. Werk een beetje aan uw project voor {}.".format(random.choice(deadlines))) - # - # parsed = les.parseArgs(day) - # - # # Invalid arguments - # if not parsed[0]: - # return await ctx.send(parsed[1]) - # - # day, dayDatetime, semester, year = parsed[1:] - # - # # Customize the user's schedule - # schedule = self.customizeSchedule(ctx, year, semester) - # - # # Create the embed - # embed = les.createEmbed(day, dayDatetime, semester, year, schedule) - # - # await ctx.send(embed=embed) + # Invalid arguments + if not parsed[0]: + return await ctx.send(parsed[1]) + + day, dayDatetime, semester, year = parsed[1:] + + # Customize the user's schedule + schedule = self.customizeSchedule(ctx, year, semester) + + # Create the embed + embed = les.createEmbed(day, dayDatetime, semester, year, schedule) + + await ctx.send(embed=embed) # Add all the user's courses def customizeSchedule(self, ctx, year, semester): diff --git a/data/remind.py b/data/remind.py index bfe4768..8c92bc2 100644 --- a/data/remind.py +++ b/data/remind.py @@ -12,7 +12,7 @@ class Reminders: self._les = [int(user[0]) for user in rows if user[2]] self._lesMessages = ["Lessenrooster voor vandaag:"] - self.les = {"users": self._les, "messages": self._lesMessages, "embed": self.lesEmbed(), "weekends": False, "disabled": True} + self.les = {"users": self._les, "messages": self._lesMessages, "embed": self.lesEmbed(), "weekends": False, "disabled": False} self.categories = [self.nightly, self.les] diff --git a/functions/les.py b/functions/les.py index 6b40e2c..822491e 100644 --- a/functions/les.py +++ b/functions/les.py @@ -24,13 +24,14 @@ def createEmbed(day, dayDatetime, semester, year, schedule): startDate = 1612224000 currentTime = dayDatetime.timestamp() + # TODO don't clamp because week 1 is calculated as week 0!! week = clamp(timeFormatters.timeIn(currentTime - startDate, "weeks")[0], 1, 13) # Compensate for easter holidays # Sorry but I don't have time to make a clean solution for this rn # this will have to do - if currentTime > 1617377400: - week -= 2 + # Does -1 instead of -2 because weeks were 0-indexed all along + week -= 1 title, week = getTitle(day, dayDatetime, week)