From 8df3ebd8c4050e34a8c79107ce6008ac1c3bce6c Mon Sep 17 00:00:00 2001 From: Lili Pavelu Date: Tue, 5 Jul 2022 15:48:09 +0200 Subject: [PATCH] early progress: more untested functionality point checking and accumulating --- main.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/main.py b/main.py index c99984f..51d113e 100644 --- a/main.py +++ b/main.py @@ -41,6 +41,26 @@ def owncastWebhook(): print("Integrity Error.") print(f"User ID {user_id} probably does not exist.") + elif data["type"] == "CHAT": + user_id = data["eventData"]["user"]["id"] + if "!points" in data["body"]: + try: + cursor = db.execute( + "SELECT points FROM points WHERE id = ?", + (user_id), + ) + print("{}'s points: {}".format(user_id, cursor.fetchone())) + else: #debug: give points for message + try: + db.execute( + "UPDATE points SET points = points + 10 WHERE id = ?", + (user_id), + ) + db.commit() + except sqlite3.Error as e: + print("Error occured:", e.args[0]) + print("To user:", user_id) + return data if __name__ == '__main__':