]> us-delaporte.pagekite.me Git - matrix-chore-bot.git/blobdiff - matrix_chore_bot/bot.py
Allow space separated done list
[matrix-chore-bot.git] / matrix_chore_bot / bot.py
index 7e33ade92560c452a0914aad5a0cceda0b6e6d47..067c2f906d196170c07c95456c669484ce0dc74c 100644 (file)
@@ -47,15 +47,24 @@ async def handle_chore(match):
       check - check status of a chore
       done - mark a chore as done
       list - print the chore list
+      filter TERM - list all chores that include TERM
       undo - mark a chore as undone
     '''
 
     if match.command('list'):
-        results = ['## Listing chores...']
+        results = ['## Listing all...']
         for item in CHORES.list():
             results.append(item)
         results.append('-- End of List --')
         return results
+
+    if match.command('filter'):
+        term = ' '.join(match.args()[1:])
+        results = [f'## List matching {term}']
+        for item in CHORES.filter(term):
+            results.append(item)
+        results.append('-- End of List --')
+        return results
     
     if match.command('setup'):
         results = []
@@ -75,9 +84,12 @@ async def handle_chore(match):
         return [result]
 
     if match.command('done'):
-        chore_id = match.args()[1]
-        result = CHORES.done(chore_id)
-        return [result]
+        ids = match.args()[1:]
+        results = []
+        for chore_id in ids:
+            result = CHORES.done(chore_id)
+            results.append(result)
+        return results
 
     if match.command('undo'):
         chore_id = match.args()[1]