diff --git a/cogs/football.py b/cogs/football.py index 1f77c85..4ad793e 100644 --- a/cogs/football.py +++ b/cogs/football.py @@ -2,7 +2,7 @@ from decorators import help from discord.ext import commands from enums.help_categories import Category from functions import checks, config -from functions.football import getMatches, getTable, get_jpl_code +from functions.football import getMatches, getTable class Football(commands.Cog): @@ -36,13 +36,6 @@ class Football(commands.Cog): async def table(self, ctx, *args): await ctx.send(getTable()) - @commands.check(checks.isMe) - @jpl.command(name="Update") - async def update(self, ctx): - code = get_jpl_code() - config.config("jpl", code) - await ctx.message.add_reaction("✅") - def setup(client): client.add_cog(Football(client)) diff --git a/files/help.json b/files/help.json index d6112ac..058ba7e 100644 --- a/files/help.json +++ b/files/help.json @@ -56,7 +56,6 @@ "jpl": "Informatie over de Jupiler Pro League.", "jpl matches": "Bekijk de wedstrijden die gespeeld worden op [Week]. Default naar de huidige speeldag.", "jpl table": "De huidige stand van het klassement.", - "jpl update": "Haalt de nieuwe code voor de competitie van dit jaar op.", "leaderboard": "Bekijk de Top 10 van [Categorie].\nIndien je geen categorie opgeeft krijg je een lijst van categorieën.", "les": "Bekijk het lessenrooster voor [Dag] in het [Jaargang]-de jaar.\nIndien je geen dag opgeeft, is dit standaard vandaag. De jaargang is standaard 2.\nLes Morgen/Overmorgen werkt ook.", "lmgtfy": "Stuur iemand een LMGTFY link wanneer ze je een domme vraag stellen in plaats van het zelf op te zoeken.\nQueries met spaties moeten **niet** tussen aanhalingstekens staan.", diff --git a/functions/football.py b/functions/football.py index 0648096..092a90c 100644 --- a/functions/football.py +++ b/functions/football.py @@ -1,20 +1,15 @@ -from typing import Optional - -from attr import dataclass, field -from datetime import datetime from enum import Enum +from attr import dataclass, field from functions.timeFormatters import fromString from functions.scrapers.sporza import getJPLMatches, getJPLTable from functions.stringFormatters import leadingZero -import re -from requests import get +from datetime import datetime import tabulate class Status(Enum): AfterToday = "--:--" NotStarted = "--:--" - Postponed = "--:--" Over = "Einde" HalfTime = "Rust" @@ -29,7 +24,7 @@ class Match: homeScore: int = 0 away: str = field(init=False) awayScore: int = 0 - start: Optional[datetime] = field(init=False) + start: datetime = field(init=False) date: str = field(init=False) weekDay: str = field(init=False) status: Status = field(init=False) @@ -47,13 +42,9 @@ class Match: self.homeScore = self.matchDict[Navigation.HomeScore.value] self.awayScore = self.matchDict[Navigation.AwayScore.value] - if "startDateTime" in self.matchDict: - self.start = fromString(self.matchDict["startDateTime"], formatString="%Y-%m-%dT%H:%M:%S.%f%z") - else: - self.start = None - - self.date = self.start.strftime("%d/%m") if self.start is not None else "Uitgesteld" - self.weekDay = self._getWeekday() if self.start is not None else "??" + self.start = fromString(self.matchDict["startDateTime"], formatString="%Y-%m-%dT%H:%M:%S.%f%z") + self.date = self.start.strftime("%d/%m") + self.weekDay = self._getWeekday() def _getStatus(self, status: str): """ @@ -74,7 +65,6 @@ class Match: statusses: dict = { "after_today": Status.AfterToday.value, "not_started": Status.NotStarted.value, - "postponed": Status.Postponed.value, "end": Status.Over.value } @@ -98,9 +88,6 @@ class Match: """ Returns a string representing the scoreboard """ - if self.start is None: - return "??" - # No score to show yet, show time when the match starts if not self._hasStarted(): return "{}:{}".format(leadingZero(str(self.start.hour)), leadingZero(str(self.start.minute))) @@ -108,7 +95,7 @@ class Match: return "{} - {}".format(self.homeScore, self.awayScore) def _hasStarted(self): - return self.status not in [Status.AfterToday.value, Status.NotStarted.value, Status.Postponed.value] + return self.status not in [Status.AfterToday.value, Status.NotStarted.value] class Navigation(Enum): @@ -175,14 +162,3 @@ def _formatRow(row): scoresArray.insert(1, row.find_all("a")[0].renderContents().decode("utf-8").split("