From ef6904243dd60c4ac08aa543fd6661d512267ffd Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Tue, 9 Aug 2022 11:48:09 -0300 Subject: Sending keyword to the todo creator --- bot.py | 7 ++++--- org.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index ec0afe0..9cd9df3 100644 --- a/bot.py +++ b/bot.py @@ -31,10 +31,11 @@ async def todo(room, message): bot: TODO added! """ match = botlib.MessageMatch(room, message, bot, PREFIX) - if match.is_not_from_this_bot() and match.prefix() and match.command("todo"): + if match.is_not_from_this_bot() and match.prefix(): user = message.sender + keyword = str(message).split()[1].replace("!", "").lower() - if user == MATRIX_USERNAME: + if user == MATRIX_USERNAME and keyword in ["todo", "repeat", "next", "waiting", "someday", "proj"]: message = " ".join(message.body.split(" ")[1:]) room_id = room.room_id splitted_message = message.split("-") @@ -54,7 +55,7 @@ async def todo(room, message): todo_extra = "" print(f"Room: {room_id}, User: {user}, Message: {message}") - OrgData().add_new_todo(todo_title, todo_objective, todo_extra) + OrgData().add_new_todo(keyword, todo_title, todo_objective, todo_extra) await bot.api.send_text_message(room_id, "TODO added!") diff --git a/org.py b/org.py index 1108d7e..dde53ae 100644 --- a/org.py +++ b/org.py @@ -18,14 +18,14 @@ class OrgData(NextCloudConnection): today_hour = today.strftime("%H:%M") return f"{today_ymd} {today_day} {today_hour}" - def add_new_todo(self, description: str, outcome: str, extra: str) -> None: + def add_new_todo(self, keyword: str, description: str, outcome: str, extra: str) -> None: self.client.download_file(ORG_CAPTURE_FILENAME, "./capture.org") today = self._generate_today() todo_template = f""" -** TODO {description} :NEW::BOT: +** {keyword.upper()} {description} :NEW::BOT: Desired outcome: {outcome} :LOGBOOK: - Added: [{today}] -- cgit v1.2.3