From c0f1d3381897abd8fd19c576b66f2f317b9ce3bd Mon Sep 17 00:00:00 2001 From: Lili Date: Wed, 24 Aug 2022 15:55:46 +0200 Subject: [PATCH] add use_points --- tlapbot/owncast_helpers.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tlapbot/owncast_helpers.py b/tlapbot/owncast_helpers.py index 1546f6f..0c7db02 100644 --- a/tlapbot/owncast_helpers.py +++ b/tlapbot/owncast_helpers.py @@ -9,7 +9,6 @@ def read_users_points(db, user_id): (user_id,) ) return cursor.fetchone()[0] - except Error as e: print("Error occured reading points:", e.args[0]) print("To user:", user_id) @@ -23,7 +22,18 @@ def give_points_to_user(db, user_id, points): db.commit() except Error as e: print("Error occured giving DEBUG points:", e.args[0]) - print("To user:", user_id) + print("To user:", user_id, " amount of points:", points) + +def use_points(db, user_id, points): + try: + db.execute( + "UPDATE points SET points = points - ? WHERE id = ?", + (points, user_id,) + ) + db.commit() + except Error as e: + print("Error occured using points:", e.args[0]) + print("From user:", user_id, " amount of points:", points) def give_points_to_chat(db): points_given = 10