Sending keyword to the todo creator
This commit is contained in:
parent
dae5518b43
commit
ef6904243d
7
bot.py
7
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!")
|
||||
|
||||
|
||||
|
4
org.py
4
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}]
|
||||
|
Loading…
x
Reference in New Issue
Block a user