]> us-delaporte.pagekite.me Git - matrix-shop-bot.git/commitdiff
List purchase history
authorEdward Delaporte <edward@delaporte.us>
Sun, 26 Apr 2026 16:07:56 +0000 (11:07 -0500)
committerEdward Delaporte <edward@delaporte.us>
Sun, 7 Jun 2026 00:29:28 +0000 (19:29 -0500)
.gitignore
app.py
matrix_shop_bot/bot.py
matrix_shop_bot/tasks.py

index d684adc9f74b033b863c6ef67139f20a9d260c7d..5950934abfeb3bdefbc6381911d89f0b920eedd9 100644 (file)
@@ -10,6 +10,7 @@ build
 *.log
 
 # Data file
+.env
 *.db
 
 # Chatbot output
diff --git a/app.py b/app.py
index eab75c7e44dd621002604e461b1d5b7e7a555167..8e005bea66ce7fac777563b15264be81a803f32d 100644 (file)
--- 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)
index 46ba972de0b86c0fbaefdd3c9d84b3b0b65d7374..ae65bdc03494b7f6166c79dc40ff607c653dcd47 100644 (file)
@@ -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']
index 8d1125ee36ff3688ab3f0aa01515459d469b81d1..515649b623f60bd1774cd01b652229b0e51768c6 100644 (file)
@@ -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)
+