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,7 +4,40 @@ from my_project_name.chat_functions import react_to_event, send_text_to_room
from my_project_name.config import Config
from my_project_name.storage import Storage
from my_project_name.caldav_handler import CaldavHandler
import json
import requests
def weekly_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 task_help():
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 = "# Tasks for this week\n"
for task in data:
message += "- {} ({}): {}\n".format(task["Name"], task["Value"], task["Description"])
return message
class Command:
def __init__(
@@ -53,6 +86,8 @@ class Command:
await self._show_week()
elif self.command.startswith("month"):
await self._show_month()
elif self.command.startswith("tasks"):
await self._show_tasks()
#else:
# await self._unknown_command()
@@ -73,6 +108,10 @@ class Command:
response = handler.print_month()
await send_text_to_room(self.client, self.room.room_id, response, markdown_convert=True)
async def _show_tasks(self):
response = task_help()
await send_text_to_room(self.client, self.room.room_id, response, markdown_convert=True)
async def _echo(self):
"""Echo back the command's arguments"""
response = " ".join(self.args)