]> us-delaporte.pagekite.me Git - matrix-goal-bot.git/commitdiff
Use last selected goal for some commands
authorEdward Delaporte <edward@delaporte.us>
Sun, 5 Apr 2026 14:28:24 +0000 (09:28 -0500)
committerEdward Delaporte <edward@delaporte.us>
Sun, 5 Apr 2026 14:28:24 +0000 (09:28 -0500)
matrix_goal_bot/bot.py
matrix_goal_bot/db.py

index 3b4f2406cba7eb7819d5ff94cf01e1fce2ee10ce..04ff0e810eaa0b54527af1d8080c30898916e3ec 100644 (file)
@@ -74,15 +74,12 @@ async def do_goal(match):
             results.append(str(goal))
         return results
 
             results.append(str(goal))
         return results
 
-
     if match.command('add.task'):
     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
         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:])
 
     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'):
         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)
         logger.debug(f'Searching for goal {goal_id}...')
         goal,tasks = Data().get_goal(goal_id)
         results = pretty_print(goal, tasks)
+
         return results
 
 
         return results
 
 
index 1e90bcfec3797fa31e0b8b1e66101bbd4b0a5cae..83017333177785aec757fc20ef30e459bc646645 100644 (file)
@@ -106,9 +106,6 @@ class Data():
             cmd = select(Vision).where(Vision.complete_date == None)
             return session.exec(cmd).all()
 
             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:
     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):
         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)
         result = self.add_with_name(Task, name)
         with Session(self.engine) as session:
             cmd = select(Task).where(Task.name == name)