Update timetable code

This commit is contained in:
Nexus 2023-09-19 09:49:01 +01:00
parent a587cd741c
commit b1a6badf12
Signed by: nex
GPG key ID: 0FA334385D0B689F
5 changed files with 111 additions and 109 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="dataSourceStorageLocal" created-in="PY-232.9559.58">
<component name="dataSourceStorageLocal" created-in="PY-232.9921.36">
<data-source name="main" uuid="28efee07-d306-4126-bf69-01008b4887e2">
<database-info product="SQLite" version="3.39.2" jdbc-version="2.1" driver-name="SQLite JDBC" driver-version="3.39.2.0" dbms="SQLITE" exact-version="3.39.2" exact-driver-version="3.39">
<identifier-quote-string>&quot;</identifier-quote-string>

View file

@ -1,4 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11 (LCC-bot)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (LCC-bot)" project-jdk-type="Python SDK" />
</project>

View file

@ -1372,6 +1372,7 @@ class OtherCog(commands.Cog):
discord.SlashCommandOptionType.attachment,
description="Image to perform OCR on",
)
):
"""OCRs an image"""
await ctx.defer()

View file

@ -152,6 +152,10 @@ class TimeTableCog(commands.Cog):
next_lesson = self.next_lesson(date)
if not next_lesson:
next_lesson = self.absolute_next_lesson()
next_lesson.setdefault("name", "unknown")
next_lesson.setdefault("tutor", "unknown")
next_lesson.setdefault("room", "unknown")
next_lesson.setdefault("start_datetime", discord.utils.utcnow())
text = (
"[tt] No more lessons today!\n"
f"[tt] Next Lesson: {next_lesson['name']!r} with {next_lesson['tutor']} in "
@ -160,20 +164,46 @@ class TimeTableCog(commands.Cog):
)
else:
text = (
f"[tt] Next Lesson: {next_lesson['name']!r} with {next_lesson['tutor']} in "
f"{next_lesson['room']} - Starts {discord.utils.format_dt(next_lesson['start_datetime'], 'R')}"
next_lesson.setdefault("name", "unknown")
next_lesson.setdefault("tutor", "unknown")
next_lesson.setdefault("room", "unknown")
next_lesson.setdefault("start_datetime", discord.utils.utcnow())
text = "[tt] Next Lesson: {0[name]!r} with {0[tutor]} in {0[room]} - Starts {1}".format(
lesson,
discord.utils.format_dt(next_lesson['start_datetime'], 'R')
)
else:
text = (
f"[tt] Current Lesson: {lesson['name']!r} with {lesson['tutor']} in {lesson['room']} - "
f"ends {discord.utils.format_dt(lesson['end_datetime'], 'R')}"
)
lesson.setdefault("name", "unknown")
lesson.setdefault("tutor", "unknown")
lesson.setdefault("room", "unknown")
lesson.setdefault("start_datetime", discord.utils.utcnow())
if lesson["name"].lower() != "lunch":
text = "[tt] Current Lesson: {0['name']!r} with {0['tutor']} in {0['room']} - ends {1}".format(
lesson,
discord.utils.format_dt(lesson['end_datetime'], 'R')
)
else:
text = "[tt] \U0001f37d\U0000fe0f Lunch! {0}-{1}, ends in {2}".format(
discord.utils.format_dt(lesson['start_datetime'], 't'),
discord.utils.format_dt(lesson['end_datetime'], 't'),
discord.utils.format_dt(lesson['end_datetime'], 'R')
)
next_lesson = self.next_lesson(date)
if next_lesson:
text += "\n[tt] Next lesson: {0[name]!r} with {0[tutor]} in {0[room]} - starts {1}".format(
next_lesson, discord.utils.format_dt(next_lesson["start_datetime"], "R")
)
next_lesson = self.absolute_next_lesson()
next_lesson.setdefault("name", "unknown")
next_lesson.setdefault("tutor", "unknown")
next_lesson.setdefault("room", "unknown")
next_lesson.setdefault("start_datetime", discord.utils.utcnow())
if lesson["name"].lower() != "lunch":
text += "\n[tt] Next lesson: {0[name]!r} with {0[tutor]} in {0[room]} - starts {1}".format(
next_lesson, discord.utils.format_dt(next_lesson["start_datetime"], "R")
)
else:
text = "[tt] \U0001f37d\U0000fe0f Lunch! {0}-{1}.".format(
discord.utils.format_dt(lesson['start_datetime'], 't'),
discord.utils.format_dt(lesson['end_datetime'], 't'),
)
if no_prefix:
text = text.replace("[tt] ", "")
@ -225,7 +255,7 @@ class TimeTableCog(commands.Cog):
await ctx.defer()
await self.update_timetable_message(ctx, date, no_prefix=True)
if random.randint(1, 10) == 1:
end_date = datetime(2023, 7, 13, 0, 0, 0, tzinfo=timezone.utc)
end_date = datetime(2024, 7, 13, 0, 0, 0, tzinfo=timezone.utc)
days_left = (end_date - discord.utils.utcnow()).days
await ctx.respond("There are only {:,} days left of this academic year.".format(days_left))

View file

@ -1,7 +1,7 @@
{
"monday": [
{
"name": "???",
"name": "Digital Security",
"start": [
9,
0
@ -10,11 +10,11 @@
10,
15
],
"tutor": "Other",
"room": "A145"
"tutor": "Raphael",
"room": "A132"
},
{
"name": "???",
"name": "Digital Security",
"start": [
10,
30
@ -23,26 +23,13 @@
11,
45
],
"tutor": "Other",
"room": "A145"
"tutor": "Raphael",
"room": "A132"
}
],
"tuesday": [
{
"name": "???",
"start": [
9,
0
],
"end": [
10,
15
],
"tutor": "Other",
"room": "A144"
},
{
"name": "???",
"name": "Managing Infrastructure",
"start": [
10,
30
@ -51,11 +38,11 @@
11,
45
],
"tutor": "Other",
"room": "A047"
"tutor": "Rebecca",
"room": "A132"
},
{
"name": "???",
"name": "Digital Security",
"start": [
11,
45
@ -64,11 +51,22 @@
13,
0
],
"tutor": "Other",
"room": "A145"
"tutor": "Raphael",
"room": "A132"
},
{
"name": "???",
"name": "Lunch",
"start": [
13,
0
],
"end": [
14,
0
]
},
{
"name": "Digital Security",
"start": [
14,
0
@ -77,39 +75,26 @@
15,
15
],
"tutor": "Other",
"room": "A047"
"tutor": "Raphael",
"room": "A132"
}
],
"wednesday": [
{
"name": "???",
"name": "Managing Infrastructure",
"start": [
9,
0
],
"end": [
10,
15
],
"tutor": "Other",
"room": "A145"
},
{
"name": "???",
"start": [
10,
30
],
"end": [
11,
45
],
"tutor": "Other",
"room": "A145"
"tutor": "Rebecca",
"room": "A132"
},
{
"name": "???",
"name": "Digital Security",
"start": [
11,
45
@ -118,11 +103,22 @@
13,
0
],
"tutor": "Other",
"room": "A145"
"tutor": "Raphael",
"room": "A132"
},
{
"name": "???",
"name": "Lunch",
"start": [
13,
0
],
"end": [
14,
0
]
},
{
"name": "Digital Security",
"start": [
14,
0
@ -131,62 +127,47 @@
15,
15
],
"tutor": "Other",
"room": "A145"
},
{
"name": "???",
"start": [
15,
30
],
"end": [
16,
45
],
"tutor": "Other",
"room": "A145"
"tutor": "Raphael",
"room": "A132"
}
],
"thursday": [
{
"name": "???",
"name": "Research & Evaluation",
"start": [
9,
0
],
"end": [
10,
15
],
"tutor": "Other",
"room": "A145"
},
{
"name": "???",
"start": [
10,
30
],
"end": [
11,
45
],
"tutor": "Other",
"room": "A145"
"tutor": "Zach",
"room": "A132"
},
{
"name": "???",
"name": "Lunch",
"start": [
11,
45
],
"end": [
13,
12,
45
]
},
{
"name": "Research & Evaluation",
"start": [
12,
45
],
"end": [
14,
0
],
"tutor": "Other",
"room": "A145"
"tutor": "Zach",
"room": "A132"
},
{
"name": "Fundamentals",
@ -199,20 +180,7 @@
15
],
"tutor": "Steven",
"room": "A145"
},
{
"name": "Fundamentals",
"start": [
15,
30
],
"end": [
16,
45
],
"tutor": "Steven",
"room": "A145"
"room": "A132"
}
],
"friday": [],