💩 add workaround to receive prayer times for the next 7 days (which is not persistet yet)
This commit is contained in:
parent
3d602eacf9
commit
c4cf6196aa
1 changed files with 9 additions and 7 deletions
|
@ -114,14 +114,16 @@ def get_praying_times(date: datetime.date, username) -> Dict[str, str]:
|
||||||
|
|
||||||
def schedule_reminder(username) -> None:
|
def schedule_reminder(username) -> None:
|
||||||
# TODO: add peristence for reminders
|
# TODO: add peristence for reminders
|
||||||
times = get_praying_times(datetime.date.today(), username)
|
|
||||||
now = datetime.datetime.now(datetime.UTC)
|
now = datetime.datetime.now(datetime.UTC)
|
||||||
for prayer, time in times.items():
|
# as a workaround until it's finished schedule the next 7 days
|
||||||
praying_time = datetime.datetime.fromisoformat(time)
|
for i in range(7):
|
||||||
if praying_time > now:
|
times = get_praying_times(datetime.date.today() + datetime.timedelta(days=i), username)
|
||||||
seconds = int((praying_time - now).total_seconds())
|
for prayer, time in times.items():
|
||||||
message = "{} is at {}".format(prayer, praying_time.strftime("%H:%M"))
|
praying_time = datetime.datetime.fromisoformat(time)
|
||||||
asyncio.ensure_future(remind(username, message, seconds - user_reminders[username] * 60))
|
if praying_time > now:
|
||||||
|
seconds = int((praying_time - now).total_seconds())
|
||||||
|
message = "{} is at {}".format(prayer, praying_time.strftime("%H:%M"))
|
||||||
|
asyncio.ensure_future(remind(username, message, seconds - user_reminders[username] * 60))
|
||||||
|
|
||||||
|
|
||||||
async def remind(username, message, seconds) -> None:
|
async def remind(username, message, seconds) -> None:
|
||||||
|
|
Loading…
Reference in a new issue