From 2593c3ba0d5dcea3fedb357b507de6abffe5c60c Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Sat, 6 Feb 2021 17:01:43 +0100 Subject: [PATCH] Re-enable les, fix schedule --- cogs/school.py | 41 +++++++++++------------------------------ files/config.json | 2 +- files/schedules/22.json | 20 ++++++++++---------- functions/les.py | 11 +++++------ 4 files changed, 27 insertions(+), 47 deletions(-) diff --git a/cogs/school.py b/cogs/school.py index a12a919..52fd18d 100644 --- a/cogs/school.py +++ b/cogs/school.py @@ -43,41 +43,22 @@ class School(commands.Cog): @commands.check(checks.allowedChannels) @help.Category(category=Category.School) async def les(self, ctx, *day): - embed = discord.Embed(colour=discord.Colour.blue()) + parsed = les.parseArgs(day) - # These are hardcoded because they don't change & don't matter anymore in a month - embed.set_author(name="Examenrooster 2de Bachelor") + # Invalid arguments + if not parsed[0]: + return await ctx.send(parsed[1]) - embed.add_field(name="Algoritmen en Datastructuren 2", - value="Woensdag 06/01/2021\n13:00 - 16:00\nFlanders Expo, Hal 4D", inline=False) - embed.add_field(name="Functioneel Programmeren", - value="Dinsdag 12/01/2021\n13:00 - 16:00\nFlanders Expo, Hal 5C", inline=False) - embed.add_field(name="Systeemprogrammeren", - value="Maandag 18/01/2021\n08:30 - 11:30\nOnline, schriftelijk", inline=False) - embed.add_field(name="Communicatienetwerken", - value="Vrijdag 22/01/2021\n13:00 - 16:00\nFlanders Expo Hal 4A", inline=False) - embed.add_field(name="Statistiek en Probabiliteit", - value="Vrijdag 29/01/2021\n08:30 - 11:30\nCampus Ardoyen Locus, PC Resto Locus", inline=False) + 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) - # Les code - # 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) - # Add all the user's courses def customizeSchedule(self, ctx, year, semester): schedule = les.getSchedule(semester, year) diff --git a/files/config.json b/files/config.json index fabdd7d..dd9aec4 100644 --- a/files/config.json +++ b/files/config.json @@ -1 +1 @@ -{"semester": "2", "year": "2", "years": 2, "jpl": 161733, "jpl_day": 22} \ No newline at end of file +{"semester": "2", "year": "2", "years": 2, "jpl": 161733, "jpl_day": 24} \ No newline at end of file diff --git a/files/schedules/22.json b/files/schedules/22.json index d9b3a76..b9c2c12 100644 --- a/files/schedules/22.json +++ b/files/schedules/22.json @@ -4,15 +4,15 @@ "zoom": "https://ufora.ugent.be/d2l/ext/rp/228912/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826", "slots": [ { - "online": "Zoom", + "online": "ZOOM", "time": ["maandag", 1000, 1300] }, { - "online": "Zoom", + "online": "ZOOM", "time": ["dinsdag", 830, 930] }, { - "online": "Zoom", + "online": "ZOOM", "time": ["donderdag", 1430, 1700] } ] @@ -22,7 +22,7 @@ "zoom": "https://ufora.ugent.be/d2l/ext/rp/236949/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826", "slots": [ { - "online": "Zoom", + "online": "ZOOM", "time": ["maandag", 1430, 1730] }, { @@ -38,15 +38,15 @@ "zoom": "https://ufora.ugent.be/d2l/ext/rp/236404/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826", "slots": [ { - "online": "Zoom", + "online": "ZOOM", "time": ["dinsdag", 1130, 1300] }, { - "online": "Zoom", + "online": "ZOOM", "time": ["woensdag", 1500, 1800] }, { - "online": "Zoom", + "online": "ZOOM", "time": ["donderdag", 830, 1000] } ] @@ -55,11 +55,11 @@ "course": "Software Engineering Lab 1", "slots": [ { - "online": "Zoom", + "online": "ZOOM", "time": ["dinsdag", 1430, 1700] }, { - "online": "Zoom", + "online": "ZOOM", "time": ["vrijdag", 830, 1130] } ] @@ -74,7 +74,7 @@ "time": ["woensdag", 900, 1100] }, { - "online": "Zoom", + "online": "ZOOM", "time": ["donderdag", 1000, 1300] } ] diff --git a/functions/les.py b/functions/les.py index c8b4229..9b6b558 100644 --- a/functions/les.py +++ b/functions/les.py @@ -21,7 +21,7 @@ def createCourseString(courses): def createEmbed(day, dayDatetime, semester, year, schedule): # Create a date object to check the current week - startDate = 1600041600 + startDate = 1612224000 currentTime = dayDatetime.timestamp() week = clamp(timeFormatters.timeIn(currentTime - startDate, "weeks")[0], 1, 13) @@ -47,12 +47,11 @@ def createEmbed(day, dayDatetime, semester, year, schedule): if extras: embed.add_field(name="Extra", value="\n".join(getExtras(extra) for extra in extras), inline=False) - # TODO uncomment this when covid rules slow down # Add online links - temporarily removed because everything is online right now - # if online: - # uniqueLinks: dict = getUniqueLinks(online) - # embed.add_field(name="Online Links", value="\n".join( - # sorted(getLinks(onlineClass, links) for onlineClass, links in uniqueLinks.items()))) + if online: + uniqueLinks: dict = getUniqueLinks(online) + embed.add_field(name="Online Links", value="\n".join( + sorted(getLinks(onlineClass, links) for onlineClass, links in uniqueLinks.items()))) embed.set_footer(text="Semester {} | Lesweek {}".format(semester, round(week))) return embed