tasks now trigger on set interval
interval is every 10 minutes per day, exactly as the final digit of the minute is 0
This commit is contained in:
parent
eb3547f604
commit
b837c54b3f
@ -4,6 +4,8 @@ Loading this file via `commands.Bot.load_extension` will add `TaskCog` to the bo
|
||||
"""
|
||||
|
||||
import logging
|
||||
import datetime
|
||||
from os import getenv
|
||||
from time import process_time
|
||||
|
||||
from discord import TextChannel
|
||||
@ -23,6 +25,16 @@ from utils import get_unparsed_feed
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
TASK_INTERVAL_MINUTES = getenv("TASK_INTERVAL_MINUTES")
|
||||
|
||||
times = [
|
||||
datetime.time(hour, minute, tzinfo=datetime.timezone.utc)
|
||||
for hour in range(24)
|
||||
for minute in range(0, 60, int(TASK_INTERVAL_MINUTES))
|
||||
]
|
||||
|
||||
log.debug("Task will trigger every %s minutes", TASK_INTERVAL_MINUTES)
|
||||
|
||||
|
||||
class TaskCog(commands.Cog):
|
||||
"""
|
||||
@ -38,11 +50,11 @@ class TaskCog(commands.Cog):
|
||||
async def on_ready(self):
|
||||
"""Instructions to call when the cog is ready."""
|
||||
|
||||
self.rss_task.start() # pylint disable=E1101
|
||||
self.rss_task.start()
|
||||
|
||||
log.info("%s cog is ready", self.__class__.__name__)
|
||||
|
||||
@tasks.loop(minutes=10)
|
||||
@tasks.loop(time=times)
|
||||
async def rss_task(self):
|
||||
"""Automated task responsible for processing rss feeds."""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user