mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-20 02:26:32 +01:00
Migrate timetable.py to logging
This commit is contained in:
parent
53ea874159
commit
9cdee767e9
1 changed files with 3 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import random
|
import random
|
||||||
from datetime import datetime, time, timedelta, timezone
|
from datetime import datetime, time, timedelta, timezone
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -22,6 +23,7 @@ def schedule_times():
|
||||||
class TimeTableCog(commands.Cog):
|
class TimeTableCog(commands.Cog):
|
||||||
def __init__(self, bot: commands.Bot):
|
def __init__(self, bot: commands.Bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
self.log = logging.getLogger("jimmy.cogs.timetable")
|
||||||
with (Path.cwd() / "utils" / "timetable.json").open() as file:
|
with (Path.cwd() / "utils" / "timetable.json").open() as file:
|
||||||
self.timetable = json.load(file)
|
self.timetable = json.load(file)
|
||||||
self.update_status.start()
|
self.update_status.start()
|
||||||
|
@ -159,7 +161,7 @@ class TimeTableCog(commands.Cog):
|
||||||
try:
|
try:
|
||||||
next_lesson = self.absolute_next_lesson(date + timedelta(days=1))
|
next_lesson = self.absolute_next_lesson(date + timedelta(days=1))
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
print("Failed to fetch absolute next lesson. Is this the end?")
|
self.log.critical("Failed to fetch absolute next lesson. Is this the end?")
|
||||||
return
|
return
|
||||||
next_lesson.setdefault("name", "unknown")
|
next_lesson.setdefault("name", "unknown")
|
||||||
next_lesson.setdefault("tutor", "unknown")
|
next_lesson.setdefault("tutor", "unknown")
|
||||||
|
|
Loading…
Reference in a new issue