From 8622ad0931a257441b96c95f183615a99b8f11ea Mon Sep 17 00:00:00 2001 From: Lili Date: Fri, 9 Sep 2022 12:35:20 +0200 Subject: [PATCH] update dashboard to show time and username time instead of datetime, username instead of user ID --- tlapbot/owncast_webhooks.py | 21 +++++++++++++++++---- tlapbot/templates/dashboard.html | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tlapbot/owncast_webhooks.py b/tlapbot/owncast_webhooks.py index a9d6a51..ea376f8 100644 --- a/tlapbot/owncast_webhooks.py +++ b/tlapbot/owncast_webhooks.py @@ -28,7 +28,13 @@ def owncast_webhook(): print("New chat message:") print(f'from {display_name}:') print(f'{data["eventData"]["body"]}') - if "!points" in data["eventData"]["body"]: + if "!help" in data["eventData"]["body"]: + message = """Tlapbot commands: + !points to see your points. + !drink to redeem a pitíčko for 60 points. + That's it for now.""" + send_chat(message) + elif "!points" in data["eventData"]["body"]: if not user_exists(db, user_id): add_user_to_database(db, user_id, display_name) points = read_users_points(db, user_id) @@ -39,11 +45,18 @@ def owncast_webhook(): if points is not None and points > 60: if use_points(db, user_id, 60): add_to_redeem_queue(db, user_id, "drink") + send_chat("Pitíčko redeemed for 60 points.") + else: + send_chat("Pitíčko not redeemed because of an error.") + else: + send_chat("Can't redeem pitíčko, you don't have enough points.") + elif "!clear" in data["eventData"]["body"]: + clear_redeem_queue(db) elif "!queue" in data["eventData"]["body"]: - queue = whole_redeem_queue(db) - print("ID | timestamp | redeem | redeemer_id ") + queue = pretty_redeem_queue(db) + print("timestamp | redeem | redeemer") for row in queue: - print(row[0], " ", row[1], " ", row[2], " ", row[3]) + print(row[0], " ", row[1], " ", row[2]) # else: # DEBUG: give points for message # give_points_to_chat(db) return data \ No newline at end of file diff --git a/tlapbot/templates/dashboard.html b/tlapbot/templates/dashboard.html index 46262fe..2799937 100644 --- a/tlapbot/templates/dashboard.html +++ b/tlapbot/templates/dashboard.html @@ -22,9 +22,9 @@ {% for row in queue %} + {{ row[0].time() }} {{ row[1] }} {{ row[2] }} - {{ row[3] }} {% endfor %}