summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Gonzalez <roger@rogs.me>2022-08-09 11:48:09 -0300
committerRoger Gonzalez <roger@rogs.me>2022-08-09 11:48:09 -0300
commitef6904243dd60c4ac08aa543fd6661d512267ffd (patch)
treec1681dcb2455d8f0b7fe834923783993fecf944f
parentdae5518b43a2bdd06d6545448fb936bbc77caad4 (diff)
Sending keyword to the todo creator
-rw-r--r--bot.py7
-rw-r--r--org.py4
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}]