From 9ce16bb35e621fea7ea91a16e12707e8ad7eff71 Mon Sep 17 00:00:00 2001 From: Lili Date: Fri, 30 Sep 2022 12:01:33 +0200 Subject: [PATCH] bugfix: only give points to unique users no longer gives people extra points for having more tabs open --- tlapbot/owncast_helpers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tlapbot/owncast_helpers.py b/tlapbot/owncast_helpers.py index 30189dd..8826571 100644 --- a/tlapbot/owncast_helpers.py +++ b/tlapbot/owncast_helpers.py @@ -16,9 +16,10 @@ def give_points_to_chat(db): 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(): + unique_users = list(set(map(lambda user_object: user_object["user"]["id"], r.json()))) + for user_id in unique_users: give_points_to_user(db, - user_object["user"]["id"], + user_id, current_app.config['POINTS_AMOUNT_GIVEN']) def send_chat(message):