'''
-Prefix: !chore
+Prefix: .fridge
Synax:
-!chore COMMAND ARGS
+.fridge 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
-filter TERM - list all chores that include TERM
-undo - mark a chore as undone
+add - add an item
+list - print the list of fresh items
+remove - remove an item
+to.toss - print the list of items to toss
+filter TERM - list all items that include TERM
'''
from datetime import datetime as dt
import simplematrixbotlib as botlib
-from .db import Data as ChoreData
+from .db import Data
logger = logging.getLogger(__name__)
logging.getLogger('nio').setLevel(logging.WARNING)
-class ChoreBot():
+MODULE='fridge'
+
+class FridgeBot():
def __init__(self, matrix_server,
bot_name,
bot_pwd,
db_file=None,
- bot_prefix='!chore'):
+ bot_prefix='.fridge'):
- logging.basicConfig(filename='matrix-chore-bot.log', encoding='utf-8', level=logging.DEBUG)
+ logging.basicConfig(filename=f'matrix-{MODULE}-bot.log', encoding='utf-8', level=logging.DEBUG)
creds = botlib.Creds(matrix_server, bot_name, bot_pwd)
self.bot = botlib.Bot(creds)
self.prefix = bot_prefix
- self.data = ChoreData(db_file=db_file)
+ self.data = Data(db_file=db_file)
def run(self):
self.bot.run()
async def _handle_match(self, match):
if match.command('list'):
- results = ['## Listing all...']
+ results = ['## Listing fresh items...']
for item in self.data.list():
results.append(item)
results.append('-- End of List --')
return results
+
+ if match.command('toss'):
+ results = ['## Listing items to toss...']
+ for item in self.data.to_toss():
+ results.append(item)
+ results.append('-- End of List --')
+ return results
+
+
if match.command('filter'):
term = ' '.join(match.args()[1:])
results = [f'## List matching {term}']
if match.command('setup'):
results = []
- results.append('Doing chore setup...')
+ results.append('Doing fridge 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)
+ new_fridge = ' '.join(match.args()[1:])
+ result = self.data.add(new_fridge)
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)
+ fridge_id = match.args()[1]
+ result = self.data.remove(fridge_id)
return [result]
return [__doc__]