From c4fc1de95c153f1a1cad2a11e6f5f3d6d5929dca Mon Sep 17 00:00:00 2001 From: Lili Date: Mon, 5 Sep 2022 13:20:20 +0200 Subject: [PATCH] configurable points per X seconds implementation --- tlapbot/default_config.py | 3 ++- tlapbot/owncast_helpers.py | 5 +++-- tlapbot/owncast_webhooks.py | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tlapbot/default_config.py b/tlapbot/default_config.py index 33803c7..c756a70 100644 --- a/tlapbot/default_config.py +++ b/tlapbot/default_config.py @@ -2,4 +2,5 @@ SECRET_KEY='dev' DATABASE='./instance/tlapbot.sqlite' OWNCAST_ACCESS_TOKEN='' OWNCAST_INSTANCE_URL='http://localhost:8080' -POINTS_PER_10_MINUTES=10 \ No newline at end of file +POINTS_CYCLE_TIME=600 +POINTS_AMOUNT_GIVEN=10 \ No newline at end of file diff --git a/tlapbot/owncast_helpers.py b/tlapbot/owncast_helpers.py index 0c7db02..3ebd90c 100644 --- a/tlapbot/owncast_helpers.py +++ b/tlapbot/owncast_helpers.py @@ -36,12 +36,13 @@ def use_points(db, user_id, points): print("From user:", user_id, " amount of points:", points) def give_points_to_chat(db): - points_given = 10 url = current_app.config['OWNCAST_INSTANCE_URL'] + '/api/integrations/clients' headers = {"Authorization": "Bearer " + current_app.config['OWNCAST_ACCESS_TOKEN']} r = requests.post(url, headers=headers) for user_object in r.json(): - give_points_to_user(db, user_object["user"]["id"], points_given) + give_points_to_user(db, + user_object["user"]["id"], + current_app.config['POINTS_AMOUNT_GIVEN']) def user_exists(db, user_id): try: diff --git a/tlapbot/owncast_webhooks.py b/tlapbot/owncast_webhooks.py index fa0f16f..a783dfb 100644 --- a/tlapbot/owncast_webhooks.py +++ b/tlapbot/owncast_webhooks.py @@ -32,6 +32,6 @@ def owncast_webhook(): if points > 60: use_points(db, user_id, 60) send_chat("Enjoy your DRINK........... sips") - else: # DEBUG: give points for message - give_points_to_chat(db) + # else: # DEBUG: give points for message + # give_points_to_chat(db) return data \ No newline at end of file