Print expired triggers separately

pull/167/head
bobloy 4 years ago
parent d5bc5993ea
commit 9c9b46dc76

@ -1,6 +1,6 @@
import logging
from datetime import datetime, timedelta
from typing import Dict, List, Optional, Union
from typing import Dict, List, Optional, Tuple, Union
import discord
from apscheduler.triggers.base import BaseTrigger
@ -190,14 +190,23 @@ class Task:
await self._decode_time_triggers()
return self.data
async def get_triggers(self) -> List[BaseTrigger]:
async def get_triggers(self) -> Tuple[List[BaseTrigger], List[BaseTrigger]]:
if not self.data:
await self.load_from_config()
if self.data is None or "triggers" not in self.data: # No triggers
return []
return [], []
trigs = []
expired_trigs = []
for t in self.data["triggers"]:
trig = get_trigger(t)
if check_expired_trigger(trig):
expired_trigs.append(t)
else:
trigs.append(t)
return [get_trigger(t) for t in self.data["triggers"]]
return trigs, expired_trigs
async def get_combined_trigger(self) -> Union[BaseTrigger, None]:
if not self.data:

Loading…
Cancel
Save