- except Exception as ex:
- line = 'Ye cannot get ye flask.'
- await bot.api.send_text_message(
- room.room_id, str(line))
-
-
-async def handle_chore(match):
- '''
- Prefix: !chore
-
- Synax:
- !chore COMMAND ARGS
-
- Commands:
- help - show this help
- add - add a chore
- check - check status of a chore
- done - mark a chore as done
- list - print the chore list
- undo - mark a chore as undone
- '''
-
- if match.command('list'):
- results = ['## Listing chores...']
- for item in CHORES.list():
- results.append(item)
- results.append('-- End of List --')
- return results
-
- if match.command('setup'):
- results = []
- results.append('Doing chore setup...')
- result = CHORES.setup()
- results.append(str(result))
- return results
-
- if match.command('add'):
- new_chore = ' '.join(match.args()[1:])
- result = CHORES.add(new_chore)
- return [result]
-
- if match.command('check'):
- chore_id = match.args()[1]
- result = CHORES.check(chore_id)
- return [result]
-
- if match.command('done'):
- chore_id = match.args()[1]
- result = CHORES.done(chore_id)
- return [result]
-
- if match.command('undo'):
- chore_id = match.args()[1]
- result = CHORES.undo(chore_id)
- return [result]
-
- if match.command('remove'):
- chore_id = match.args()[1]
- result = CHORES.remove(chore_id)
- return [result]
-
- return [handle_chore.__doc__]
+
+
+ async def _handle_match(self, match):
+
+ if match.command('list'):
+ results = ['## Listing all...']
+ for item in self.data.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 self.data.filter(term):
+ results.append(item)
+ results.append('-- End of List --')
+ return results
+
+ if match.command('setup'):
+ results = []
+ results.append('Doing chore setup...')
+ result = self.data.setup()
+ results.append(str(result))
+ return results
+
+ if match.command('add'):
+ new_chore = ' '.join(match.args()[1:])
+ result = self.data.add(new_chore)
+ return [result]
+
+ if match.command('check'):
+ chore_id = match.args()[1]
+ result = self.data.check(chore_id)
+ return [result]
+
+ if match.command('done'):
+ ids = match.args()[1:]
+ results = []
+ for chore_id in ids:
+ result = self.data.done(chore_id)
+ results.append(result)
+ return results
+
+ if match.command('undo'):
+ chore_id = match.args()[1]
+ result = self.data.undo(chore_id)
+ return [result]
+
+ if match.command('remove'):
+ chore_id = match.args()[1]
+ result = self.data.remove(chore_id)
+ return [result]
+
+ return [__doc__]