From 5d5875d17e5d680b1a8c9f63a9e23a869333bf4c Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Sat, 29 Apr 2023 17:27:32 -0700 Subject: [PATCH] Only post the outage once --- app/cogs/star_citizen.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/cogs/star_citizen.py b/app/cogs/star_citizen.py index 4390d75d..9470af13 100644 --- a/app/cogs/star_citizen.py +++ b/app/cogs/star_citizen.py @@ -28,7 +28,7 @@ class StarCitizen(commands.Cog): embed = await star_citizen.get_ship(ship_name=ship) await ctx.send_followup(embed=embed) - @tasks.loop(seconds=60) + @tasks.loop(seconds=5) async def poll_status_page(self): # Wait until the bot is ready before we actually start executing code await self.bot.wait_until_ready() @@ -40,7 +40,8 @@ class StarCitizen(commands.Cog): current_status = soup.find("div", {"class": "global-status"}).findNext("span") - if current_status.text != "Operational": + self.notified = 0 + if current_status.text != "Operational" and self.notified == 0: # Find the lastest incident latest_incident = current_status.findNext("h2") details = latest_incident.findNext("div", {"class": "markdown"}) @@ -62,6 +63,9 @@ class StarCitizen(commands.Cog): ) channel = await self.bot.get_channel(1097567909640929340).send(embed=embed) + self.notified = 1 + else: + self.notified = 0 def setup(bot):