From: Edward Delaporte Date: Sun, 5 Apr 2026 14:28:24 +0000 (-0500) Subject: Use last selected goal for some commands X-Git-Url: https://us-delaporte.pagekite.me/gitweb/matrix-goal-bot.git/commitdiff_plain/08aa0bb297ebc364cd6b0bc725169c9116454baa?ds=sidebyside Use last selected goal for some commands --- diff --git a/matrix_goal_bot/bot.py b/matrix_goal_bot/bot.py index 3b4f240..04ff0e8 100644 --- a/matrix_goal_bot/bot.py +++ b/matrix_goal_bot/bot.py @@ -74,15 +74,12 @@ async def do_goal(match): results.append(str(goal)) return results - if match.command('add.task'): - goal_id = int(match.args()[1]) - new = ' '.join(match.args()[2:]) - result = Data().add_task(goal_id=goal_id, name=new) + new = ' '.join(match.args()[1:]) + result = Data().quick_add_task(new) goal,tasks = Data().get_goal(goal_id) results = pretty_print(goal, tasks) return results - # return [f'Added task with id {result}'] if match.command('add.vision'): new = ' '.join(match.args()[1:]) @@ -90,10 +87,15 @@ async def do_goal(match): return [f'Vision added with id {result}'] if match.command('print'): - goal_id = int(match.args()[1]) + if len(match.args()) > 1: + goal_id = int(match.args()[1]) + else: + goal_id = Data()._get_pref_goal_id() + logger.debug(f'Searching for goal {goal_id}...') goal,tasks = Data().get_goal(goal_id) results = pretty_print(goal, tasks) + return results diff --git a/matrix_goal_bot/db.py b/matrix_goal_bot/db.py index 1e90bcf..8301733 100644 --- a/matrix_goal_bot/db.py +++ b/matrix_goal_bot/db.py @@ -106,9 +106,6 @@ class Data(): cmd = select(Vision).where(Vision.complete_date == None) return session.exec(cmd).all() - def print_ophan_tasks(self): - pass - def get_all_goals(self): '''List all goals''' with Session(self.engine) as session: @@ -203,7 +200,6 @@ class Data(): return self.add_task(goal_id, name) def add_task(self, goal_id, name): - self._set_pref_goal_id(goal_id) result = self.add_with_name(Task, name) with Session(self.engine) as session: cmd = select(Task).where(Task.name == name)