]> apps.delaporte.us Git - matrix-goal-bot.git/commitdiff
Rebasing
authorEdward Delaporte <edward@delaporte.us>
Wed, 8 Apr 2026 22:07:03 +0000 (17:07 -0500)
committerEdward Delaporte <edward@delaporte.us>
Wed, 8 Apr 2026 22:07:03 +0000 (17:07 -0500)
matrix_goal_bot/bot.py
matrix_goal_bot/db.py
matrix_goal_bot/tasks.py

index fd8fdcad380bed6d9e23f56c694f2157958a9cca..37cb90db1a418f2b7a0bbc3c99717b2064687d86 100644 (file)
@@ -10,9 +10,6 @@ SERVER = os.environ.get('MATRIX_SERVER')
 BOT_NAME = os.environ.get('GOAL_BOT')
 BOT_PWD = os.environ.get('GOAL_BOT_PWD')
 
-def get_bot():
-    creds = botlib.Creds(SERVER, BOT_NAME, BOT_PWD)
-    return botlib.Bot(creds)
 
 DATE_FORMAT = '%Y-%m-%d'
 
@@ -177,6 +174,11 @@ async def do_goal(match):
         results = pretty_print(goal, tasks)
         return results
 
+    if match.command('remove'):
+        task_id  = int(match.args()[1])
+        result = Data().remove_task(task_id)
+        return [result]
+
     if match.command('extra.help'):
         return [ex_help]
 
index 9ab3898935fb4dca3700e291e0f1b187c0218404..6a73021017b16b353b2e515b412f82ab30c245c0 100644 (file)
@@ -205,6 +205,16 @@ class Data():
             session.commit()
         return goal_id
 
+    def remove_task(self, task_id):
+        task_name = ''
+        with Session(self.engine) as session:
+            cmd = select(Task).where(Task.id  == task_id)
+            to_remove = session.exec(cmd).first()
+            task_name = to_remove.name
+            session.delete(to_remove)
+            session.commit()
+        return f'Removed task "{task_name}"'
+
     def assign_vision(self, goal_id, vision_id):
         '''Goals may move between visions'''
         self._set_pref_goal_id(goal_id)
index 5eb9bf7dfac1e9c13d74122ecaeaf8d3048703d0..be2004f0a4fba375ca9661052c122a68797c15a9 100644 (file)
@@ -29,6 +29,12 @@ def add_task(c, goal_id, name):
     result = Data().add_task(goal_id=goal_id, name=name)
     print(result)
 
+@task
+def remove_task(c, goal_id, name):
+    result = Data().add_task(goal_id=goal_id, name=name)
+    print(result)
+
+
 
 @task
 def list(c):