diff --git a/my_project_name/__pycache__/__init__.cpython-39.pyc b/my_project_name/__pycache__/__init__.cpython-39.pyc index 3080c73..a25b87e 100644 Binary files a/my_project_name/__pycache__/__init__.cpython-39.pyc and b/my_project_name/__pycache__/__init__.cpython-39.pyc differ diff --git a/my_project_name/__pycache__/bot_commands.cpython-39.pyc b/my_project_name/__pycache__/bot_commands.cpython-39.pyc index cd0ef6e..17839a4 100644 Binary files a/my_project_name/__pycache__/bot_commands.cpython-39.pyc and b/my_project_name/__pycache__/bot_commands.cpython-39.pyc differ diff --git a/my_project_name/__pycache__/caldav_handler.cpython-39.pyc b/my_project_name/__pycache__/caldav_handler.cpython-39.pyc index 629dbe1..73146d7 100644 Binary files a/my_project_name/__pycache__/caldav_handler.cpython-39.pyc and b/my_project_name/__pycache__/caldav_handler.cpython-39.pyc differ diff --git a/my_project_name/__pycache__/callbacks.cpython-39.pyc b/my_project_name/__pycache__/callbacks.cpython-39.pyc index 8897f01..cb5ca67 100644 Binary files a/my_project_name/__pycache__/callbacks.cpython-39.pyc and b/my_project_name/__pycache__/callbacks.cpython-39.pyc differ diff --git a/my_project_name/__pycache__/chat_functions.cpython-39.pyc b/my_project_name/__pycache__/chat_functions.cpython-39.pyc index 7751ab4..558b0a5 100644 Binary files a/my_project_name/__pycache__/chat_functions.cpython-39.pyc and b/my_project_name/__pycache__/chat_functions.cpython-39.pyc differ diff --git a/my_project_name/__pycache__/config.cpython-39.pyc b/my_project_name/__pycache__/config.cpython-39.pyc index 214e9d4..9ee7f01 100644 Binary files a/my_project_name/__pycache__/config.cpython-39.pyc and b/my_project_name/__pycache__/config.cpython-39.pyc differ diff --git a/my_project_name/__pycache__/errors.cpython-39.pyc b/my_project_name/__pycache__/errors.cpython-39.pyc index f7c59ad..7d1d9cc 100644 Binary files a/my_project_name/__pycache__/errors.cpython-39.pyc and b/my_project_name/__pycache__/errors.cpython-39.pyc differ diff --git a/my_project_name/__pycache__/main.cpython-39.pyc b/my_project_name/__pycache__/main.cpython-39.pyc index 8ad9c6e..7b21a9f 100644 Binary files a/my_project_name/__pycache__/main.cpython-39.pyc and b/my_project_name/__pycache__/main.cpython-39.pyc differ diff --git a/my_project_name/__pycache__/message_responses.cpython-39.pyc b/my_project_name/__pycache__/message_responses.cpython-39.pyc index 50e68d7..d4a83e4 100644 Binary files a/my_project_name/__pycache__/message_responses.cpython-39.pyc and b/my_project_name/__pycache__/message_responses.cpython-39.pyc differ diff --git a/my_project_name/__pycache__/storage.cpython-39.pyc b/my_project_name/__pycache__/storage.cpython-39.pyc index 0e8a820..e3efac3 100644 Binary files a/my_project_name/__pycache__/storage.cpython-39.pyc and b/my_project_name/__pycache__/storage.cpython-39.pyc differ diff --git a/my_project_name/bot_commands.py b/my_project_name/bot_commands.py index 972a5ef..1ff6969 100644 --- a/my_project_name/bot_commands.py +++ b/my_project_name/bot_commands.py @@ -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) diff --git a/my_project_name/main.py b/my_project_name/main.py index c921dc2..e8b59f2 100644 --- a/my_project_name/main.py +++ b/my_project_name/main.py @@ -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