add task reminder

This commit is contained in:
2024-06-17 21:56:53 +02:00
parent 2c48fd997e
commit 465a4c2f03
12 changed files with 60 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import logging
import threading
import sys
from time import sleep
import datetime
from aiohttp import ClientConnectionError, ServerDisconnectedError
from nio import (
@@ -28,6 +29,22 @@ logger = logging.getLogger(__name__)
from datetime import datetime, time
def weekly_task_reminder():
api_url = "https://tasklist.malobeo.org/api/next"
response = requests.get(api_url)
if response.status_code != 200:
return "Error requesting " + api_url + " Status Code: " + str(response.status_code)
data = response.json()
message = "# Weekly Task Reminder\n"
for task in data:
message += "- {}: **{}**\n".format(task["Name"], task["Value"])
message += "\n*Write* ```!c tasks``` *to get details about the tasks*"
return message
def is_time_between(begin_time, end_time, check_time=None):
# If check time is not given, default to current UTC time
check_time = check_time or datetime.utcnow().time()
@@ -46,6 +63,10 @@ async def foo(client):
messages = handler.send_reminders()
for message in messages:
await send_text_to_room(client, "!aRFGSGKGeaBxiEfDMC:matrix.org", message)
if datetime.datetime.today().weekday() == 1: #check if its tuesday
await send_text_to_room(client, "!aRFGSGKGeaBxiEfDMC:matrix.org", weekly_task_reminder())
ShouldSendReminder = False
else:
ShouldSendReminder = True