]> us-delaporte.pagekite.me Git - matrix-goal-bot.git/blobdiff - bot.py
Add ability to complete tasks
[matrix-goal-bot.git] / bot.py
diff --git a/bot.py b/bot.py
index 731113d2c053a9db0047298683dd752aff315e5c..649cfe69e753333464ed4dd65cb6ee02ad218a7b 100644 (file)
--- a/bot.py
+++ b/bot.py
@@ -4,7 +4,7 @@ import os
 
 import simplematrixbotlib as botlib
 
 
 import simplematrixbotlib as botlib
 
-from goals.db import Data
+from goals.db import Data, pretty_print
 
 
 SERVER = os.environ.get('MATRIX_SERVER')
 
 
 SERVER = os.environ.get('MATRIX_SERVER')
@@ -59,17 +59,26 @@ async def do_goal(match):
         goal_id = int(match.args()[1])
         logger.debug(f'Searching for goal {goal_id}...')
         goal,tasks = Data().get_goal(goal_id)
         goal_id = int(match.args()[1])
         logger.debug(f'Searching for goal {goal_id}...')
         goal,tasks = Data().get_goal(goal_id)
+        results = pretty_print(goal, tasks)
+        return results
 
 
-        results = []
-        results.append(f' ## {goal}')
-        for task in tasks:
-            if(task.complete_date):
-                results.append(f' - [x] {task}')
-            else:
-                results.append(f' - [ ] {task}')
+    if match.command('goal-done'):
+        goal_id = int(match.args()[1])
+        logger.debug(f'Searching for goal {goal_id}...')
+        Data().complete_goal(goal_id)
+        goal,tasks = Data().get_goal(goal_id)
+        results = pretty_print(goal, tasks)
         return results
     
         return results
     
-    return 'Ye flask must be load bearing or something.'
+
+    if match.command('done'):
+        task_id = int(match.args()[1])
+        goal_id = Data().complete_task(task_id)
+        goal,tasks = Data().get_goal(goal_id)
+        results = pretty_print(goal, tasks)
+        return results
+
+    return __doc__
 
 
 @bot.listener.on_message_event
 
 
 @bot.listener.on_message_event