mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-20 02:26:32 +01:00
Merge branch 'master' of https://github.com/EEKIM10/LCC-bot
This commit is contained in:
commit
ca26ef0673
6 changed files with 129 additions and 121 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<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">
|
<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">
|
<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>"</identifier-quote-string>
|
<identifier-quote-string>"</identifier-quote-string>
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<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" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (LCC-bot)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
|
@ -990,16 +990,11 @@ class OtherCog(commands.Cog):
|
||||||
# Assume is timestamp
|
# Assume is timestamp
|
||||||
timestamp = round(float(parsed_qs['t'][0]))
|
timestamp = round(float(parsed_qs['t'][0]))
|
||||||
end_timestamp = None
|
end_timestamp = None
|
||||||
if len(parsed_qs["t"]) == 2:
|
if len(parsed_qs["t"]) >= 2:
|
||||||
end_timestamp = round(float(parsed_qs['t'][1]))
|
end_timestamp = round(float(parsed_qs['t'][1]))
|
||||||
if end_timestamp < timestamp:
|
if end_timestamp < timestamp:
|
||||||
return await ctx.edit(
|
end_timestamp, timestamp = reversed(
|
||||||
embed=discord.Embed(
|
(end_timestamp, timestamp)
|
||||||
title="Error",
|
|
||||||
description="End timestamp must be greater than start timestamp.",
|
|
||||||
colour=discord.Colour.red()
|
|
||||||
),
|
|
||||||
delete_after=30
|
|
||||||
)
|
)
|
||||||
_end = "to %s" % end_timestamp if len(parsed_qs["t"]) == 2 else "onward"
|
_end = "to %s" % end_timestamp if len(parsed_qs["t"]) == 2 else "onward"
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
|
@ -1377,6 +1372,7 @@ class OtherCog(commands.Cog):
|
||||||
discord.SlashCommandOptionType.attachment,
|
discord.SlashCommandOptionType.attachment,
|
||||||
description="Image to perform OCR on",
|
description="Image to perform OCR on",
|
||||||
)
|
)
|
||||||
|
|
||||||
):
|
):
|
||||||
"""OCRs an image"""
|
"""OCRs an image"""
|
||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import random
|
import random
|
||||||
import sys
|
|
||||||
import asyncio
|
|
||||||
from typing import Optional, Union, Dict
|
from typing import Optional, Union, Dict
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
@ -53,6 +51,9 @@ class TimeTableCog(commands.Cog):
|
||||||
|
|
||||||
blocks = [f"```\nTimetable for {date.strftime('%A')} ({date.strftime('%d/%m/%Y')}):\n```"]
|
blocks = [f"```\nTimetable for {date.strftime('%A')} ({date.strftime('%d/%m/%Y')}):\n```"]
|
||||||
for lesson in lessons:
|
for lesson in lessons:
|
||||||
|
lesson.setdefault("name", "unknown")
|
||||||
|
lesson.setdefault("tutor", "unknown")
|
||||||
|
lesson.setdefault("room", "unknown")
|
||||||
start_datetime = date.replace(hour=lesson["start"][0], minute=lesson["start"][1])
|
start_datetime = date.replace(hour=lesson["start"][0], minute=lesson["start"][1])
|
||||||
end_datetime = date.replace(hour=lesson["end"][0], minute=lesson["end"][1])
|
end_datetime = date.replace(hour=lesson["end"][0], minute=lesson["end"][1])
|
||||||
text = (
|
text = (
|
||||||
|
@ -136,6 +137,10 @@ class TimeTableCog(commands.Cog):
|
||||||
_break = self.are_on_break(date)
|
_break = self.are_on_break(date)
|
||||||
if _break is not None:
|
if _break is not None:
|
||||||
next_lesson = self.absolute_next_lesson(date + timedelta(days=1))
|
next_lesson = self.absolute_next_lesson(date + timedelta(days=1))
|
||||||
|
next_lesson.setdefault("name", "unknown")
|
||||||
|
next_lesson.setdefault("tutor", "unknown")
|
||||||
|
next_lesson.setdefault("room", "unknown")
|
||||||
|
next_lesson.setdefault("start_datetime", discord.utils.utcnow())
|
||||||
text = (
|
text = (
|
||||||
"[tt] On break {!r} from {} until {}. Break ends {}, and the first lesson back is "
|
"[tt] On break {!r} from {} until {}. Break ends {}, and the first lesson back is "
|
||||||
"{lesson[name]!r} with {lesson[tutor]} in {lesson[room]}.".format(
|
"{lesson[name]!r} with {lesson[tutor]} in {lesson[room]}.".format(
|
||||||
|
@ -150,8 +155,16 @@ class TimeTableCog(commands.Cog):
|
||||||
lesson = self.current_lesson(date)
|
lesson = self.current_lesson(date)
|
||||||
if not lesson:
|
if not lesson:
|
||||||
next_lesson = self.next_lesson(date)
|
next_lesson = self.next_lesson(date)
|
||||||
if not next_lesson:
|
if next_lesson is None:
|
||||||
next_lesson = self.absolute_next_lesson()
|
try:
|
||||||
|
next_lesson = self.absolute_next_lesson(date + timedelta(days=1))
|
||||||
|
except RuntimeError:
|
||||||
|
print("Failed to fetch absolute next lesson. Is this the end?")
|
||||||
|
return
|
||||||
|
next_lesson.setdefault("name", "unknown")
|
||||||
|
next_lesson.setdefault("tutor", "unknown")
|
||||||
|
next_lesson.setdefault("room", "unknown")
|
||||||
|
next_lesson.setdefault("start_datetime", discord.utils.utcnow())
|
||||||
text = (
|
text = (
|
||||||
"[tt] No more lessons today!\n"
|
"[tt] No more lessons today!\n"
|
||||||
f"[tt] Next Lesson: {next_lesson['name']!r} with {next_lesson['tutor']} in "
|
f"[tt] Next Lesson: {next_lesson['name']!r} with {next_lesson['tutor']} in "
|
||||||
|
@ -160,20 +173,45 @@ class TimeTableCog(commands.Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
text = (
|
next_lesson.setdefault("name", "unknown")
|
||||||
f"[tt] Next Lesson: {next_lesson['name']!r} with {next_lesson['tutor']} in "
|
next_lesson.setdefault("tutor", "unknown")
|
||||||
f"{next_lesson['room']} - Starts {discord.utils.format_dt(next_lesson['start_datetime'], 'R')}"
|
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(
|
||||||
|
next_lesson,
|
||||||
|
discord.utils.format_dt(next_lesson['start_datetime'], 'R')
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
text = (
|
lesson.setdefault("name", "unknown")
|
||||||
f"[tt] Current Lesson: {lesson['name']!r} with {lesson['tutor']} in {lesson['room']} - "
|
lesson.setdefault("tutor", "unknown")
|
||||||
f"ends {discord.utils.format_dt(lesson['end_datetime'], 'R')}"
|
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)
|
next_lesson = self.next_lesson(date)
|
||||||
if next_lesson:
|
if next_lesson:
|
||||||
text += "\n[tt] Next lesson: {0[name]!r} with {0[tutor]} in {0[room]} - starts {1}".format(
|
next_lesson.setdefault("name", "unknown")
|
||||||
next_lesson, discord.utils.format_dt(next_lesson["start_datetime"], "R")
|
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:
|
if no_prefix:
|
||||||
text = text.replace("[tt] ", "")
|
text = text.replace("[tt] ", "")
|
||||||
|
@ -225,7 +263,7 @@ class TimeTableCog(commands.Cog):
|
||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
await self.update_timetable_message(ctx, date, no_prefix=True)
|
await self.update_timetable_message(ctx, date, no_prefix=True)
|
||||||
if random.randint(1, 10) == 1:
|
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
|
days_left = (end_date - discord.utils.utcnow()).days
|
||||||
await ctx.respond("There are only {:,} days left of this academic year.".format(days_left))
|
await ctx.respond("There are only {:,} days left of this academic year.".format(days_left))
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
[pycodestyle]
|
[pycodestyle]
|
||||||
max-line-length = 120
|
max-line-length = 120
|
||||||
ignore = W293,W291
|
ignore = W293,W291
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
max-line-length = 120
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"monday": [
|
"monday": [
|
||||||
{
|
{
|
||||||
"name": "???",
|
"name": "Digital Security",
|
||||||
"start": [
|
"start": [
|
||||||
9,
|
9,
|
||||||
0
|
0
|
||||||
|
@ -10,11 +10,11 @@
|
||||||
10,
|
10,
|
||||||
15
|
15
|
||||||
],
|
],
|
||||||
"tutor": "Other",
|
"tutor": "Raphael",
|
||||||
"room": "A145"
|
"room": "A132"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "???",
|
"name": "Digital Security",
|
||||||
"start": [
|
"start": [
|
||||||
10,
|
10,
|
||||||
30
|
30
|
||||||
|
@ -23,26 +23,13 @@
|
||||||
11,
|
11,
|
||||||
45
|
45
|
||||||
],
|
],
|
||||||
"tutor": "Other",
|
"tutor": "Raphael",
|
||||||
"room": "A145"
|
"room": "A132"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tuesday": [
|
"tuesday": [
|
||||||
{
|
{
|
||||||
"name": "???",
|
"name": "Managing Infrastructure",
|
||||||
"start": [
|
|
||||||
9,
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
10,
|
|
||||||
15
|
|
||||||
],
|
|
||||||
"tutor": "Other",
|
|
||||||
"room": "A144"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "???",
|
|
||||||
"start": [
|
"start": [
|
||||||
10,
|
10,
|
||||||
30
|
30
|
||||||
|
@ -51,11 +38,11 @@
|
||||||
11,
|
11,
|
||||||
45
|
45
|
||||||
],
|
],
|
||||||
"tutor": "Other",
|
"tutor": "Rebecca",
|
||||||
"room": "A047"
|
"room": "A132"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "???",
|
"name": "Digital Security",
|
||||||
"start": [
|
"start": [
|
||||||
11,
|
11,
|
||||||
45
|
45
|
||||||
|
@ -64,11 +51,22 @@
|
||||||
13,
|
13,
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"tutor": "Other",
|
"tutor": "Raphael",
|
||||||
"room": "A145"
|
"room": "A132"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "???",
|
"name": "Lunch",
|
||||||
|
"start": [
|
||||||
|
13,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"end": [
|
||||||
|
14,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Digital Security",
|
||||||
"start": [
|
"start": [
|
||||||
14,
|
14,
|
||||||
0
|
0
|
||||||
|
@ -77,39 +75,26 @@
|
||||||
15,
|
15,
|
||||||
15
|
15
|
||||||
],
|
],
|
||||||
"tutor": "Other",
|
"tutor": "Raphael",
|
||||||
"room": "A047"
|
"room": "A132"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"wednesday": [
|
"wednesday": [
|
||||||
{
|
{
|
||||||
"name": "???",
|
"name": "Managing Infrastructure",
|
||||||
"start": [
|
"start": [
|
||||||
9,
|
9,
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"end": [
|
|
||||||
10,
|
|
||||||
15
|
|
||||||
],
|
|
||||||
"tutor": "Other",
|
|
||||||
"room": "A145"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "???",
|
|
||||||
"start": [
|
|
||||||
10,
|
|
||||||
30
|
|
||||||
],
|
|
||||||
"end": [
|
"end": [
|
||||||
11,
|
11,
|
||||||
45
|
45
|
||||||
],
|
],
|
||||||
"tutor": "Other",
|
"tutor": "Rebecca",
|
||||||
"room": "A145"
|
"room": "A132"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "???",
|
"name": "Digital Security",
|
||||||
"start": [
|
"start": [
|
||||||
11,
|
11,
|
||||||
45
|
45
|
||||||
|
@ -118,11 +103,22 @@
|
||||||
13,
|
13,
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"tutor": "Other",
|
"tutor": "Raphael",
|
||||||
"room": "A145"
|
"room": "A132"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "???",
|
"name": "Lunch",
|
||||||
|
"start": [
|
||||||
|
13,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"end": [
|
||||||
|
14,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Digital Security",
|
||||||
"start": [
|
"start": [
|
||||||
14,
|
14,
|
||||||
0
|
0
|
||||||
|
@ -131,62 +127,47 @@
|
||||||
15,
|
15,
|
||||||
15
|
15
|
||||||
],
|
],
|
||||||
"tutor": "Other",
|
"tutor": "Raphael",
|
||||||
"room": "A145"
|
"room": "A132"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "???",
|
|
||||||
"start": [
|
|
||||||
15,
|
|
||||||
30
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
16,
|
|
||||||
45
|
|
||||||
],
|
|
||||||
"tutor": "Other",
|
|
||||||
"room": "A145"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"thursday": [
|
"thursday": [
|
||||||
{
|
{
|
||||||
"name": "???",
|
"name": "Research & Evaluation",
|
||||||
"start": [
|
"start": [
|
||||||
9,
|
9,
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"end": [
|
|
||||||
10,
|
|
||||||
15
|
|
||||||
],
|
|
||||||
"tutor": "Other",
|
|
||||||
"room": "A145"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "???",
|
|
||||||
"start": [
|
|
||||||
10,
|
|
||||||
30
|
|
||||||
],
|
|
||||||
"end": [
|
"end": [
|
||||||
11,
|
11,
|
||||||
45
|
45
|
||||||
],
|
],
|
||||||
"tutor": "Other",
|
"tutor": "Zach",
|
||||||
"room": "A145"
|
"room": "A132"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "???",
|
"name": "Lunch",
|
||||||
"start": [
|
"start": [
|
||||||
11,
|
11,
|
||||||
45
|
45
|
||||||
],
|
],
|
||||||
"end": [
|
"end": [
|
||||||
13,
|
12,
|
||||||
|
45
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Research & Evaluation",
|
||||||
|
"start": [
|
||||||
|
12,
|
||||||
|
45
|
||||||
|
],
|
||||||
|
"end": [
|
||||||
|
14,
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"tutor": "Other",
|
"tutor": "Zach",
|
||||||
"room": "A145"
|
"room": "A132"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Fundamentals",
|
"name": "Fundamentals",
|
||||||
|
@ -199,20 +180,7 @@
|
||||||
15
|
15
|
||||||
],
|
],
|
||||||
"tutor": "Steven",
|
"tutor": "Steven",
|
||||||
"room": "A145"
|
"room": "A132"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Fundamentals",
|
|
||||||
"start": [
|
|
||||||
15,
|
|
||||||
30
|
|
||||||
],
|
|
||||||
"end": [
|
|
||||||
16,
|
|
||||||
45
|
|
||||||
],
|
|
||||||
"tutor": "Steven",
|
|
||||||
"room": "A145"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"friday": [],
|
"friday": [],
|
||||||
|
|
Loading…
Reference in a new issue