From: Edward Delaporte Date: Sun, 26 Apr 2026 16:07:56 +0000 (-0500) Subject: List purchase history X-Git-Url: https://apps.delaporte.us/gitweb/matrix-shop-bot.git/commitdiff_plain/68a445e04d48d94dc64145e3bce009f94d4d1eaf?ds=sidebyside List purchase history --- diff --git a/.gitignore b/.gitignore index d684adc..5950934 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ build *.log # Data file +.env *.db # Chatbot output diff --git a/app.py b/app.py index eab75c7..8e005be 100644 --- a/app.py +++ b/app.py @@ -5,8 +5,8 @@ import simplematrixbotlib as botlib from matrix_shop_bot.bot import shop_bot SERVER = os.environ.get('MATRIX_SERVER') -BOT_NAME = os.environ.get('NEW_BOT') -BOT_PWD = os.environ.get('NEW_BOT_PWD') +BOT_NAME = os.environ.get('MATRIX_BOT') +BOT_PWD = os.environ.get('MATRIX_BOT_PWD') def get_bot(): creds = botlib.Creds(SERVER, BOT_NAME, BOT_PWD) diff --git a/matrix_shop_bot/bot.py b/matrix_shop_bot/bot.py index 46ba972..ae65bdc 100644 --- a/matrix_shop_bot/bot.py +++ b/matrix_shop_bot/bot.py @@ -121,6 +121,16 @@ async def do_shop(match): results.append(str(item)) return results + + if match.command('past'): + store_name = ' '.join(match.args()[1:]) + items = Data().list_purchases(store_name) + results = ['Past purchases at {store_name}'] + for item in items: + results.append(str(item)) + return results + + if match.command('unsorted'): items = Data().get_unsorted_list() results = ['Items assigned to no store'] diff --git a/matrix_shop_bot/tasks.py b/matrix_shop_bot/tasks.py index 8d1125e..515649b 100644 --- a/matrix_shop_bot/tasks.py +++ b/matrix_shop_bot/tasks.py @@ -88,3 +88,9 @@ def remove_item(c, item_id): def remove_store(c, store_id): Data().remove_store(store_id) +@task +def list_purchases(c, store): + items = Data().list_purchases(store) + for item in items: + print(item) +