Update warnings
This commit is contained in:
parent
26bd231920
commit
e436571ea8
1 changed files with 3 additions and 2 deletions
|
@ -31,12 +31,13 @@ async def unwarn(bot: Snake) -> None:
|
||||||
logger.debug("Starting Task-unwarn")
|
logger.debug("Starting Task-unwarn")
|
||||||
while True:
|
while True:
|
||||||
max_ts = datetime.now(tz=timezone.utc) + timedelta(minutes=55)
|
max_ts = datetime.now(tz=timezone.utc) + timedelta(minutes=55)
|
||||||
warns = Warning.find(q(active=True, created_at__lte=max_ts))
|
warns = Warning.find(q(active=True, expires_at__lte=max_ts, id__nin=queue))
|
||||||
async for warn in warns:
|
async for warn in warns:
|
||||||
if warn.id in queue:
|
if warn.id in queue:
|
||||||
|
logger.warn("Warning found despite filter")
|
||||||
continue
|
continue
|
||||||
coro = _unwarn(warn)
|
coro = _unwarn(warn)
|
||||||
when = warn.created_at + timedelta(hours=warn.duration)
|
when = warn.expires_at
|
||||||
asyncio.create_task(runat(when, coro, logger))
|
asyncio.create_task(runat(when, coro, logger))
|
||||||
queue.append(warn.id)
|
queue.append(warn.id)
|
||||||
# Check every hour
|
# Check every hour
|
||||||
|
|
Loading…
Add table
Reference in a new issue