early progress: more untested functionality

point checking and accumulating
This commit is contained in:
Lili (Tlapka) 2022-07-05 15:48:09 +02:00
parent de9294c754
commit 8df3ebd8c4
1 changed files with 20 additions and 0 deletions

20
main.py
View File

@ -41,6 +41,26 @@ def owncastWebhook():
print("Integrity Error.") print("Integrity Error.")
print(f"User ID {user_id} probably does not exist.") 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 return data
if __name__ == '__main__': if __name__ == '__main__':