Announcements work + task

This commit is contained in:
Stijn De Clercq 2021-03-03 18:04:31 +01:00
parent ade7f8b72e
commit 779a84828b
8 changed files with 145 additions and 13 deletions

View file

@ -6,6 +6,7 @@ from functions import timeFormatters
from functions.config import config
from functions.database import currency, poke, prison, birthdays, stats
from functions.scraping import getMatchweek
from functions import ufora_notifications
import json
import random
import requests
@ -24,6 +25,7 @@ class Tasks(commands.Cog):
self.updateMessageCounts.start()
self.sendReminders.start()
self.updateMatchweek.start()
self.uforaAnnouncements.start()
@tasks.loop(hours=1.0)
async def bankInterest(self):
@ -238,6 +240,25 @@ class Tasks(commands.Cog):
async def beforeUpdateMatchweek(self):
await self.client.wait_until_ready()
@tasks.loop(minutes=2)
async def uforaAnnouncements(self):
"""
Task that checks for new Ufora announcements every few minutes
"""
# Get new notifications
announcements = ufora_notifications.run()
if announcements:
# TODO change to COC Bot testing if it works
announcements_channel = self.client.get_channel(int(constants.ZandbakSpeeltuin))
for an in announcements:
await announcements_channel.send(embed=an.to_embed())
@uforaAnnouncements.before_loop
async def beforeUforaAnnouncements(self):
await self.client.wait_until_ready()
def getCurrentHour(self):
return timeFormatters.dateTimeNow().hour