]> us-delaporte.pagekite.me Git - matrix-goal-bot.git/blobdiff - matrix_goal_bot/bot.py
Allow renaming goals
[matrix-goal-bot.git] / matrix_goal_bot / bot.py
index 9c0bec0e754a6965220a7e4154d6a3ef274b21ea..97f9bd7754694e6697427e86811943103ba3d7d9 100644 (file)
@@ -66,7 +66,7 @@ async def do_goal(match):
         return results
 
 
-    if match.command('list-done'):
+    if match.command('list.done'):
         goals = Data().get_done_goals()
         results = ['# Completed Goals...']
         for goal in goals:
@@ -74,7 +74,7 @@ async def do_goal(match):
         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)
@@ -83,7 +83,7 @@ async def do_goal(match):
         return results
     # return [f'Added task with id {result}']
 
-    if match.command('add-vision'):
+    if match.command('add.vision'):
         new = ' '.join(match.args()[1:])
         result = Data().add_vision(new)
         return [f'Vision added with id {result}']
@@ -96,27 +96,26 @@ async def do_goal(match):
         return results
 
 
-    if match.command('print-vision'):
+    if match.command('print.vision'):
         get_id = int(match.args()[1])
         vision,goals = Data().get_vision(get_id)
         results = pretty_print(vision, goals)
         return results
 
-    if match.command('close-goal'):
+    if match.command('close.goal'):
         goal_id = int(match.args()[1])
         vision_id = Data().complete_goal(goal_id)
         vision,goals = Data().get_vision(vision_id)
         results = pretty_print(vision, goals)
         return results
 
-    if match.command('close-vision'):
+    if match.command('close.vision'):
         vision_id = int(match.args()[1])
         Data().complete_vision(vision_id)
         vision,goals = Data().get_vision(vision_id)
         results = pretty_print(vision, goals)
         return results
 
-
     if match.command('done'):
         task_id = int(match.args()[1])
         goal_id = Data().complete_task(task_id)
@@ -124,7 +123,7 @@ async def do_goal(match):
         results = pretty_print(goal, tasks)
         return results
 
-    if match.command('list-all'):
+    if match.command('list.all'):
         goals = Data().get_all_goals()
         results = ['# Everything is...']
         for goal in goals:
@@ -143,8 +142,17 @@ async def do_goal(match):
             results.append(item)
         return results
 
+    if match.command('visions'):
+        items = Data().visionless()
+        results = ['# Goals with no vision']
+        if not items:
+            results.append('-- No visionless goals --')
+
+        for item in items:
+            results.append(item)
+        return results
 
-    if match.command('set-vision'):
+    if match.command('set.vision'):
         goal_id = int(match.args()[1])
         vision_id = int(match.args()[2])
         Data().assign_vision(goal_id=goal_id, vision_id=vision_id)
@@ -152,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):
@@ -167,6 +185,8 @@ async def goal_bot(room, message, bot):
                 await bot.api.send_text_message(
                     room.room_id, str(line))
     except Exception as ex:
-        return ['Ye cannot get ye flask.']
-
+        line ='Ye cannot get ye flask.'
+        await bot.api.send_text_message(
+                    room.room_id, str(line))
+