more style fixes everywhere else

This commit is contained in:
2022-10-17 18:47:30 +02:00
parent 06114022da
commit d8230da013
5 changed files with 34 additions and 15 deletions
+17 -3
View File
@@ -5,6 +5,7 @@ import click
from flask.cli import with_appcontext
from tlapbot.db import get_db
# # # requests stuff # # #
def is_stream_live():
url = current_app.config['OWNCAST_INSTANCE_URL'] + '/api/status'
@@ -12,6 +13,7 @@ def is_stream_live():
print(r.json()["online"])
return r.json()["online"]
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']}
@@ -22,6 +24,7 @@ def give_points_to_chat(db):
user_id,
current_app.config['POINTS_AMOUNT_GIVEN'])
def send_chat(message):
url = current_app.config['OWNCAST_INSTANCE_URL'] + '/api/integrations/chat/send'
headers = {"Authorization": "Bearer " + current_app.config['OWNCAST_ACCESS_TOKEN']}
@@ -41,6 +44,7 @@ def read_users_points(db, user_id):
print("Error occured reading points:", e.args[0])
print("To user:", user_id)
def give_points_to_user(db, user_id, points):
try:
db.execute(
@@ -52,6 +56,7 @@ def give_points_to_user(db, user_id, points):
print("Error occured giving points:", e.args[0])
print("To user:", user_id, " amount of points:", points)
def use_points(db, user_id, points):
try:
db.execute(
@@ -65,27 +70,29 @@ def use_points(db, user_id, points):
print("From user:", user_id, " amount of points:", points)
return False
def user_exists(db, user_id):
try:
cursor = db.execute(
"SELECT points FROM points WHERE id = ?",
(user_id,)
)
if cursor.fetchone() == None:
if cursor.fetchone() is None:
return False
return True
except Error as e:
print("Error occured checking if user exists:", e.args[0])
print("To user:", user_id)
""" Adds a new user to the database. Does nothing if user is already in."""
def add_user_to_database(db, user_id, display_name):
""" Adds a new user to the database. Does nothing if user is already in."""
try:
cursor = db.execute(
"SELECT points FROM points WHERE id = ?",
(user_id,)
)
if cursor.fetchone() == None:
if cursor.fetchone() is None:
cursor.execute(
"INSERT INTO points(id, name, points) VALUES(?, ?, 10)",
(user_id, display_name)
@@ -95,6 +102,7 @@ def add_user_to_database(db, user_id, display_name):
print("Error occured adding user to db:", e.args[0])
print("To user:", user_id, display_name)
def change_display_name(db, user_id, new_name):
try:
cursor = db.execute(
@@ -118,6 +126,7 @@ def add_to_counter(db, counter_name):
print("Error occured adding to counter:", e.args[0])
print("To counter:", counter_name)
def add_to_redeem_queue(db, user_id, redeem_name, note=None):
try:
cursor = db.execute(
@@ -129,6 +138,7 @@ def add_to_redeem_queue(db, user_id, redeem_name, note=None):
print("Error occured adding to redeem queue:", e.args[0])
print("To user:", user_id, " with redeem:", redeem_name, "with note:", note)
def clear_redeem_queue(db):
try:
cursor = db.execute(
@@ -141,6 +151,7 @@ def clear_redeem_queue(db):
except Error as e:
print("Error occured deleting redeem queue:", e.args[0])
def all_counters(db):
try:
cursor = db.execute(
@@ -150,6 +161,7 @@ def all_counters(db):
except Error as e:
print("Error occured selecting all counters:", e.args[0])
def pretty_redeem_queue(db):
try:
cursor = db.execute(
@@ -162,6 +174,7 @@ def pretty_redeem_queue(db):
except Error as e:
print("Error occured selecting pretty redeem queue:", e.args[0])
def whole_redeem_queue(db):
try:
cursor = db.execute(
@@ -171,6 +184,7 @@ def whole_redeem_queue(db):
except Error as e:
print("Error occured selecting redeem queue:", e.args[0])
@click.command('clear-queue')
@with_appcontext
def clear_queue_command():