Compare commits

..

No commits in common. "298a1e13d65fe56e5a7941b462706f66d26f6b1e" and "ad1175f6cd8c94e10b4ee0a5ceb5858474bcc119" have entirely different histories.

5 changed files with 99 additions and 313 deletions

View File

@ -42,9 +42,9 @@ class School(commands.Cog):
embed.set_footer(text="Omwille van de coronamaatregelen is er een beperkter aanbod, en kan je enkel nog eten afhalen. Ter plaatse eten is niet meer mogelijk.") embed.set_footer(text="Omwille van de coronamaatregelen is er een beperkter aanbod, en kan je enkel nog eten afhalen. Ter plaatse eten is niet meer mogelijk.")
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="Les", aliases=["Class", "Classes", "Sched", "Schedule"], usage="[Dag]*") # @commands.command(name="Les", aliases=["Class", "Classes", "Sched", "Schedule"], usage="[Dag]*")
# @commands.check(checks.allowedChannels) # @commands.check(checks.allowedChannels)
@help.Category(category=Category.School) # @help.Category(category=Category.School)
async def les(self, ctx, day=None): async def les(self, ctx, day=None):
date = les.find_target_date(day) date = les.find_target_date(day)

View File

@ -143,7 +143,6 @@ class Schedule:
self.schedule_dict: Dict = self.load_schedule_file() self.schedule_dict: Dict = self.load_schedule_file()
self.start_date = fromArray(self.schedule_dict["semester_start"]) self.start_date = fromArray(self.schedule_dict["semester_start"])
self.end_date = fromArray(self.schedule_dict["semester_end"]) self.end_date = fromArray(self.schedule_dict["semester_end"])
self._forward_to_semester()
# Semester is over # Semester is over
if self.end_date < self.day: if self.end_date < self.day:
@ -168,14 +167,6 @@ class Schedule:
self.weekday_str = intToWeekday(self.day.weekday()) self.weekday_str = intToWeekday(self.day.weekday())
def _forward_to_semester(self):
"""
In case the semester hasn't started yet, fast forward the current date
by a week until it's no longer necessary
"""
while self.day < self.start_date:
self.day += timedelta(weeks=1)
def check_holidays(self): def check_holidays(self):
""" """
Do all holiday-related stuff here to avoid multiple loops Do all holiday-related stuff here to avoid multiple loops
@ -243,22 +234,6 @@ class Schedule:
return HolidayEmbed(self) return HolidayEmbed(self)
slots: List[List[Timeslot]] = [self.find_slots_for_course(course) for course in self.schedule_dict["schedule"]] slots: List[List[Timeslot]] = [self.find_slots_for_course(course) for course in self.schedule_dict["schedule"]]
minor_slots = {}
# Find minor slots
for minor in self.schedule_dict["minors"]:
m_slots = []
for course in minor["schedule"]:
# Go over every course
m_slots.append(self.find_slots_for_course(course))
# Flatten list
m_slots = [item for sublist in m_slots for item in sublist]
# Sort by timestamp
m_slots.sort(key=lambda x: x.start_time)
minor_slots[minor["name"]] = m_slots
slots_flattened = [item for sublist in slots for item in sublist] slots_flattened = [item for sublist in slots for item in sublist]
# Sort by timestamp # Sort by timestamp
@ -269,7 +244,7 @@ class Schedule:
if not not_canceled: if not not_canceled:
return NoClassEmbed(self, slots_flattened) return NoClassEmbed(self, slots_flattened)
return ScheduleEmbed(self, slots_flattened, not_canceled, minor_slots) return ScheduleEmbed(self, slots_flattened, not_canceled)
@dataclass @dataclass
@ -295,9 +270,6 @@ class LesEmbed(ABC):
def get_extras(self) -> str: def get_extras(self) -> str:
return "" return ""
def add_minors(self, embed: Embed):
pass
def get_online_links(self) -> str: def get_online_links(self) -> str:
return "" return ""
@ -317,8 +289,6 @@ class LesEmbed(ABC):
if links: if links:
embed.add_field(name="Online links", value=links, inline=False) embed.add_field(name="Online links", value=links, inline=False)
self.add_minors(embed)
# Add extras if there are any # Add extras if there are any
extras = self.get_extras() extras = self.get_extras()
if extras: if extras:
@ -362,27 +332,10 @@ class ScheduleEmbed(LesEmbed):
""" """
slots: List[Timeslot] slots: List[Timeslot]
slots_not_canceled: List[Timeslot] slots_not_canceled: List[Timeslot]
minor_slots: Dict[str, List[Timeslot]]
def get_description(self) -> str: def get_description(self) -> str:
return "\n".join(list(f"{entry}" for entry in self.slots_not_canceled)) return "\n".join(list(f"{entry}" for entry in self.slots_not_canceled))
def add_minors(self, embed: Embed):
for minor, slots in self.minor_slots.items():
if not slots:
continue
not_canceled = list(filter(lambda x: not x.canceled, slots))
info = "\n".join(list(str(entry) for entry in not_canceled))
special = list(filter(lambda x: x.is_special or x.canceled, slots))
# Add extra info about this minor
if special:
info += "\n" + "\n".join(list(entry.get_special_fmt_str() for entry in special))
embed.add_field(name=f"Minor {minor}", value=info, inline=False)
def get_extras(self) -> str: def get_extras(self) -> str:
special = list(filter(lambda x: x.is_special or x.canceled, self.slots)) special = list(filter(lambda x: x.is_special or x.canceled, self.slots))

View File

@ -1,295 +1,136 @@
{ {
"semester_start": [27, 9, 2021], "semester_start": [1, 7, 2021],
"semester_end": [23, 12, 2021], "semester_end": [1, 8, 2021],
"holidays": [ "holidays": [
{ {
"start_date": [1, 11, 2021, 0, 0, 0], "start_date": [2, 7, 2021, 23, 59, 59],
"end_date": [2, 11, 2021, 23, 59, 59] "end_date": [10, 8, 2021, 23, 59, 59]
},
{
"start_date": [11, 11, 2021, 0, 0, 0],
"end_date": [11, 11, 2021, 23, 59, 59]
}
],
"minors": [
{
"name": "Beveiliging en parallelle systemen",
"online_links": {
"zoom": "https://ufora.ugent.be/d2l/ext/rp/439235/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826"
},
"schedule": [
{
"course": "Modelleren en Simuleren",
"slots": [
{
"location": {
"campus": "Sterre",
"building": "S12",
"room": "0.1"
},
"time": {
"day": "maandag",
"start": 1000,
"end": 1300
}
},
{
"location": {
"campus": "Sterre",
"building": "S9",
"room": "3.1 Konrad Zuse"
},
"time": {
"day": "dinsdag",
"start": 1130,
"end": 1300
}
},
{
"location": {
"campus": "Sterre",
"building": "S9",
"room": "3.1 Konrad Zuse"
},
"time": {
"day": "donderdag",
"start": 1430,
"end": 1600
}
}
]
},
{
"course": "Parallelle Computersystemen",
"online_links": {
"zoom": "https://ufora.ugent.be/d2l/ext/rp/449671/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826"
},
"slots": [
{
"location": {
"campus": "Ardoyen",
"building": "iGent 126",
"room": "Auditorium 1"
},
"time": {
"day": "woensdag",
"start": 1430,
"end": 1730
}
},
{
"location": {
"campus": "Ardoyen",
"building": "iGent 126",
"room": "Auditorium 1"
},
"time": {
"day": "vrijdag",
"start": 830,
"end": 1130
}
}
]
}
]
},
{
"name": "Elektrotechniek en Telecommunicatie",
"schedule": [
{
"course": "Inleiding tot Telecommunicatie",
"slots": [
{
"location": {
"campus": "Ardoyen",
"building": "iGent 125",
"room": "Systems"
},
"time": {
"day": "maandag",
"start": 1000,
"end": 1300
}
},
{
"location": {
"campus": "Ardoyen",
"building": "iGent 125",
"room": "Systems"
},
"time": {
"day": "dinsdag",
"start": 1300,
"end": 1600
}
}
]
},
{
"course": "Wiskundige Modellering",
"slots": [
{
"location": {
"campus": "Sterre",
"building": "S9",
"room": "1.1"
},
"time": {
"day": "maandag",
"start": 830,
"end": 1000
}
},
{
"location": {
"campus": "Sterre",
"building": "S8",
"room": "3.2"
},
"time": {
"day": "donderdag",
"start": 1430,
"end": 1600
}
},
{
"location": {
"campus": "Sterre",
"building": "S8",
"room": "3.2"
},
"time": {
"day": "vrijdag",
"start": 830,
"end": 1130
}
}
]
}
]
},
{
"name": "Onderwijs",
"schedule": []
} }
], ],
"schedule": [ "schedule": [
{ {
"course": "Algoritmen en Datastructuren 3", "course": "Computerarchitectuur",
"online_links": { "online_links": {
"zoom": "https://ufora.ugent.be/d2l/ext/rp/437923/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826" "zoom": "https://ufora.ugent.be/d2l/ext/rp/228912/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826",
"msteams": "https://teams.microsoft.com/l/team/19%3ad7295f0bc4634a61b461504d4a7134b3%40thread.tacv2/conversations?groupId=8755cb96-1ef5-4ea3-b806-eeebf8a85ae8&tenantId=d7811cde-ecef-496c-8f91-a1786241b99c"
},
"slots": [
]
},
{
"course": "Multimedia",
"online_links": {
"zoom": "https://ugent-be.zoom.us/j/94248831947?pwd=ZCt4UnBLSzViZnFEQmkzWE5SYnF2QT09"
}, },
"slots": [ "slots": [
{ {
"location": { "location": {
"campus": "Sterre", "campus": "Sterre",
"building": "S9", "building": "S9",
"room": "3.1 Konrad Zuse" "room": "A3"
},
"time": {
"day": "dinsdag",
"start": 830,
"end": 1000
}
},
{
"location": {
"campus": "Sterre",
"building": "S9",
"room": "1.1 Alan Turing"
},
"time": {
"day": "dinsdag",
"start": 1000,
"end": 1130
}
},
{
"location": {
"campus": "Sterre",
"building": "S9",
"room": "1.1 Alan Turing"
}, },
"time": { "time": {
"day": "woensdag", "day": "woensdag",
"start": 830, "start": 1130,
"end": 1130 "end": 1330
}
},
{
"online": "zoom",
"time": {
"day": "vrijdag",
"start": 1300,
"end": 1530
} }
} }
] ]
}, },
{ {
"course": "Artificiële Intelligentie", "course": "Wetenschappelijk Rekenen",
"online_links": { "online_links": {
"zoom": "https://ufora.ugent.be/d2l/ext/rp/439739/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826" "zoom": "https://ufora.ugent.be/d2l/ext/rp/236404/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826"
}, },
"slots": [ "slots": [
{ {
"location": { "online": "zoom",
"campus": "Sterre",
"building": "S8",
"room": "0.1"
},
"time": { "time": {
"day": "maandag", "day": "dinsdag",
"start": 1430,
"end": 1730
}
},
{
"location": {
"campus": "Sterre",
"building": "S9",
"room": "1.1 Alan Turing"
},
"time": {
"day": "woensdag",
"start": 1130, "start": 1130,
"end": 1300 "end": 1300
} }
}, },
{ {
"location": { "online": "zoom",
"campus": "Sterre", "time": {
"building": "S9", "day": "woensdag",
"room": "3.1 Konrad Zuse" "start": 1500,
}, "end": 1800
}
},
{
"online": "zoom",
"time": { "time": {
"day": "donderdag", "day": "donderdag",
"start": 1300, "start": 830,
"end": 1430 "end": 1000
} }
} }
] ]
}, },
{ {
"course": "Besturingssystemen", "course": "Software Engineering Lab 1",
"online_links": { "online_links": {
"zoom": "https://ufora.ugent.be/d2l/ext/rp/442814/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826" "zoom": "https://ufora.ugent.be/d2l/ext/rp/235800/lti/framedlaunch/556e197e-e87b-4c27-be5d-53adc7a41826",
"msteams": "https://teams.microsoft.com/l/team/19%3a4dfd5b2fb1ae4aa9b72706aa3a0d6867%40thread.tacv2/conversations?groupId=256d5c58-5d53-43f5-9436-497b0c852c75&tenantId=d7811cde-ecef-496c-8f91-a1786241b99c"
}, },
"slots": [ "slots": [
{ {
"location": { "online": "msteams",
"campus": "Ardoyen",
"building": "iGent 126",
"room": "Auditorium 1"
},
"time": { "time": {
"day": "donderdag", "day": "dinsdag",
"start": 830, "start": 1430,
"end": 1130 "end": 1700
} }
}, },
{ {
"location": { "online": "msteams",
"campus": "Ardoyen",
"building": "iGent 126",
"room": "Auditorium 1"
},
"time": { "time": {
"day": "vrijdag", "day": "vrijdag",
"start": 1300, "start": 830,
"end": 1600 "end": 1130
}
}
]
},
{
"course": "Webdevelopment",
"online_links": {
"zoom": "https://ugent-be.zoom.us/j/93166767783?pwd=MWdvb1BnNnlPSnAyNk52QmRzdjcwdz09"
},
"slots": [
{
"weeks": {
"6": {
"canceled": true
}
},
"location": {
"campus": "Sterre",
"building": "S9",
"room": "A3"
},
"time": {
"day": "woensdag",
"start": 900,
"end": 1100
}
},
{
"online": "zoom",
"time": {
"day": "donderdag",
"start": 1000,
"end": 1300
} }
} }
] ]

View File

@ -1,28 +1,21 @@
import re import re
from data.embeds import UforaNotification
import feedparser import feedparser
from data.embeds import UforaNotification
import json import json
from settings import UFORA_TOKEN
course_urls = { course_urls = {
"Algoritmen en Datastructuren 3": "https://ufora.ugent.be/d2l/le/news/rss/437923/course?token=", "Algoritmen en Datastructuren 2": "https://ufora.ugent.be/d2l/le/news/rss/222018/course?token=aehhv6utkf46t8cc102e0&ou=222018",
"Artificiële Intelligentie": "https://ufora.ugent.be/d2l/le/news/rss/439739/course?token=", "Communicatienetwerken": "https://ufora.ugent.be/d2l/le/news/rss/221184/course?token=aehhv6utkf46t8cc102e0&ou=221184",
"Automaten, Berekenbaarheid en Complexiteit": "https://ufora.ugent.be/d2l/le/news/rss/439079/course?token=", "Computerarchitectuur": "https://ufora.ugent.be/d2l/le/news/rss/228912/course?token=aehhv6utkf46t8cc102e0&ou=228912",
"Besturingssystemen": "https://ufora.ugent.be/d2l/le/news/rss/442814/course?token=", "Functioneel Programmeren": "https://ufora.ugent.be/d2l/le/news/rss/236396/course?token=aehhv6utkf46t8cc102e0&ou=236396",
"Communicatienetwerken": "https://ufora.ugent.be/d2l/le/news/rss/447014/course?token=", "Multimedia": "https://ufora.ugent.be/d2l/le/news/rss/236949/course?token=aehhv6utkf46t8cc102e0&ou=236949",
"Computationele Biologie": "https://ufora.ugent.be/d2l/le/news/rss/448904/course?token=", "Software Engineering Lab 1": "https://ufora.ugent.be/d2l/le/news/rss/235800/course?token=aehhv6utkf46t8cc102e0&ou=235800",
"Computerarchitectuur": "https://ufora.ugent.be/d2l/le/news/rss/439172/course?token=", "Statistiek en Probabiliteit": "https://ufora.ugent.be/d2l/le/news/rss/236398/course?token=aehhv6utkf46t8cc102e0&ou=236398",
"Informatiebeveiliging": "https://ufora.ugent.be/d2l/le/news/rss/444476/course?token=", "Systeemprogrammeren": "https://ufora.ugent.be/d2l/le/news/rss/222035/course?token=aehhv6utkf46t8cc102e0&ou=222035",
"Inleiding tot Telecommunicatie": "https://ufora.ugent.be/d2l/le/news/rss/450232/course?token=", "Webdevelopment": "https://ufora.ugent.be/d2l/le/news/rss/223449/course?token=aehhv6utkf46t8cc102e0&ou=223449",
"Logisch Programmeren": "https://ufora.ugent.be/d2l/le/news/rss/443368/course?token=", "Wetenschappelijk Rekenen": "https://ufora.ugent.be/d2l/le/news/rss/236404/course?token=aehhv6utkf46t8cc102e0&ou=236404"
"Modelleren en Simuleren": "https://ufora.ugent.be/d2l/le/news/rss/439235/course?token=",
"Parallelle Computersystemen": "https://ufora.ugent.be/d2l/le/news/rss/449671/course?token=",
"Software Engineering Lab 2": "https://ufora.ugent.be/d2l/le/news/rss/445170/course?token=",
"Statistiek en Probabiliteit": "https://ufora.ugent.be/d2l/le/news/rss/445169/course?token=",
"Wetenschappelijk Rekenen": "https://ufora.ugent.be/d2l/le/news/rss/445174/course?token=",
"Wiskundige Modellering": "https://ufora.ugent.be/d2l/le/news/rss/446530/course?token="
} }
@ -43,7 +36,7 @@ def run():
notifications[course] = [] notifications[course] = []
# Get the updated feed # Get the updated feed
feed = feedparser.parse(f"url{UFORA_TOKEN}") feed = feedparser.parse(url)
# Filter out old notifications # Filter out old notifications
feed = list(filter(lambda f: _parse_ids(f["id"])[0] not in notifications[course], feed.entries)) feed = list(filter(lambda f: _parse_ids(f["id"])[0] not in notifications[course], feed.entries))

View File

@ -21,7 +21,6 @@ SANDBOX = _to_bool(os.getenv("SANDBOX", "true"))
URBANDICTIONARY = os.getenv("URBANDICTIONARY", "") URBANDICTIONARY = os.getenv("URBANDICTIONARY", "")
IMGFLIP_NAME = os.getenv("IMGFLIPNAME", "") IMGFLIP_NAME = os.getenv("IMGFLIPNAME", "")
IMGFLIP_PASSWORD = os.getenv("IMGFLIPPASSWORD", "") IMGFLIP_PASSWORD = os.getenv("IMGFLIPPASSWORD", "")
UFORA_TOKEN = os.getenv("UFORA_TOKEN", "")
# Database credentials # Database credentials
DB_USERNAME = os.getenv("DBUSERNAME", "") DB_USERNAME = os.getenv("DBUSERNAME", "")