From: Edward Delaporte Date: Sun, 5 Apr 2026 09:01:36 +0000 (-0500) Subject: Allow renaming goals X-Git-Url: https://us-delaporte.pagekite.me/gitweb/matrix-goal-bot.git/commitdiff_plain/33eb98119c73f926a8cd1c7d169dda07e6d66959 Allow renaming goals --- diff --git a/matrix_goal_bot/bot.py b/matrix_goal_bot/bot.py index 9e0b878..97f9bd7 100644 --- a/matrix_goal_bot/bot.py +++ b/matrix_goal_bot/bot.py @@ -160,6 +160,16 @@ async def do_goal(match): results = pretty_print(vision, goals) return results + + if match.command('rename'): + goal_id = int(match.args()[1]) + name = ' '.join(match.args()[2:]) + Data().rename_goal(goal_id=goal_id, name=name) + goal,tasks = Data().get_goal(goal_id) + results = pretty_print(goal, tasks) + return results + + # Help text return [do_goal.__doc__] async def goal_bot(room, message, bot): diff --git a/matrix_goal_bot/db.py b/matrix_goal_bot/db.py index 97ea2c0..cd2faa9 100644 --- a/matrix_goal_bot/db.py +++ b/matrix_goal_bot/db.py @@ -136,6 +136,17 @@ class Data(): session.commit() return vision_id + def rename_goal(self, goal_id, name): + vision_id = -1 + with Session(self.engine) as session: + cmd = select(Goal).where(Goal.id == goal_id) + goal = session.exec(cmd).first() + goal.name = name + vision_id = goal.vision_id + session.commit() + return vision_id + + def complete_task(self, id): with Session(self.engine) as session: cmd = select(Task).where(Task.id == id) diff --git a/matrix_goal_bot/tasks.py b/matrix_goal_bot/tasks.py index 5e85d18..5eb9bf7 100644 --- a/matrix_goal_bot/tasks.py +++ b/matrix_goal_bot/tasks.py @@ -12,6 +12,18 @@ def add_goal(c, name): result = Data().add_goal(name) print(result) +@task +def close_goal(c, goal_id): + result = Data().complete_goal(goal_id) + print(result) + + +@task +def rename_goal(c, goal_id, name): + result = Data().rename_goal(goal_id, name) + print(result) + + @task def add_task(c, goal_id, name): result = Data().add_task(goal_id=goal_id, name=name)