diff --git a/didier/cogs/tasks.py b/didier/cogs/tasks.py index cf0164e..81136b8 100644 --- a/didier/cogs/tasks.py +++ b/didier/cogs/tasks.py @@ -73,6 +73,7 @@ class Tasks(commands.Cog): self.remove_old_ufora_announcements.start() # Start other tasks + self.init_schedules.start() self.reminders.start() self.reset_wordle_word.start() self.pull_schedules.start() @@ -134,6 +135,16 @@ class Tasks(commands.Cog): async def _before_check_birthdays(self): await self.client.wait_until_ready() + @tasks.loop(count=1) + async def init_schedules(self, **kwargs): + """Tasks that loads the schedules in memory on startup""" + _ = kwargs + await self.client.load_schedules() + + @init_schedules.before_loop + async def _before_init_schedules(self): + await self.client.wait_until_ready() + @tasks.loop(minutes=15) async def pull_free_games(self, **kwargs): """Task that checks for free games occasionally""" diff --git a/didier/data/embeds/free_games.py b/didier/data/embeds/free_games.py index 6ef94d8..f930435 100644 --- a/didier/data/embeds/free_games.py +++ b/didier/data/embeds/free_games.py @@ -70,6 +70,8 @@ class FreeGameEmbed(EmbedPydantic): if "steam" in store: self.store_page = await get_steam_webpage_info(http_session, self.link) + elif "epic" in store: + self.link = "https://store.epicgames.com/free-games" if self.store_page is not None and self.store_page.url is not None: self.link = self.store_page.url diff --git a/didier/data/rss_feeds/free_games.py b/didier/data/rss_feeds/free_games.py index 6aa576b..fcc02c9 100644 --- a/didier/data/rss_feeds/free_games.py +++ b/didier/data/rss_feeds/free_games.py @@ -5,7 +5,7 @@ import feedparser from aiohttp import ClientSession from sqlalchemy.ext.asyncio import AsyncSession -from database.crud.free_games import filter_present_games +from database.crud.free_games import add_free_games, filter_present_games from didier.data.embeds.free_games import SEPARATOR, FreeGameEmbed logger = logging.getLogger(__name__) @@ -40,7 +40,7 @@ async def fetch_free_games(http_session: ClientSession, database_session: AsyncS filtered_ids = await filter_present_games(database_session, game_ids) # Insert new games into the database - # await add_free_games(database_session, filtered_ids) TODO uncomment + await add_free_games(database_session, filtered_ids) games = list(filter(lambda x: x.dc_identifier in filtered_ids, games)) diff --git a/didier/data/scrapers/common.py b/didier/data/scrapers/common.py index 963496e..3eafcd2 100644 --- a/didier/data/scrapers/common.py +++ b/didier/data/scrapers/common.py @@ -6,7 +6,6 @@ from bs4 import BeautifulSoup, Tag __all__ = ["GameStorePage", "parse_open_graph_tags"] -# TODO make this an ABC that all other store pages implement instead @dataclass class GameStorePage: """Dataclass for information on a game's store page""" diff --git a/didier/didier.py b/didier/didier.py index ed1dd5b..cd82ec8 100644 --- a/didier/didier.py +++ b/didier/didier.py @@ -78,9 +78,6 @@ class Didier(commands.Bot): # Create directories that are ignored on GitHub self._create_ignored_directories() - # Load schedules - await self.load_schedules() - # Load the Wordle dictionary self._load_wordle_words()