code skeleton fixes
This commit is contained in:
parent
099525f9ff
commit
ede1cca8da
|
@ -1,6 +1,7 @@
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from tlapbot.db import get_db
|
from tlapbot.db import get_db
|
||||||
from tlapbot.owncast_helpers import use_points, add_to_redeem_queue
|
from tlapbot.owncast_helpers import (use_points, add_to_redeem_queue,
|
||||||
|
add_to_counter, read_users_points, send_chat)
|
||||||
|
|
||||||
def handle_redeem(message, user_id)
|
def handle_redeem(message, user_id)
|
||||||
split_message = message[1:].split(maxsplit=1)
|
split_message = message[1:].split(maxsplit=1)
|
||||||
|
@ -11,11 +12,12 @@ def handle_redeem(message, user_id)
|
||||||
note = split_message[1]
|
note = split_message[1]
|
||||||
|
|
||||||
if redeem in current_app.config['REDEEMS']:
|
if redeem in current_app.config['REDEEMS']:
|
||||||
|
db = get_db()
|
||||||
price = current_app.config['REDEEMS'][redeem]["price"]
|
price = current_app.config['REDEEMS'][redeem]["price"]
|
||||||
redeem_type = current_app.config['REDEEMS'][redeem]["type"]
|
redeem_type = current_app.config['REDEEMS'][redeem]["type"]
|
||||||
points = read_users_points(db, user_id)
|
points = read_users_points(db, user_id)
|
||||||
if points is not None and points >= price:
|
if points is not None and points >= price:
|
||||||
if use_points(db, user_id, redeem):
|
if use_points(db, user_id, price):
|
||||||
if redeem_type == "counter":
|
if redeem_type == "counter":
|
||||||
add_to_counter(db, redeem)
|
add_to_counter(db, redeem)
|
||||||
elif redeem_type == "list":
|
elif redeem_type == "list":
|
||||||
|
@ -25,11 +27,10 @@ def handle_redeem(message, user_id)
|
||||||
add_to_redeem_queue(db, user_id, redeem, note)
|
add_to_redeem_queue(db, user_id, redeem, note)
|
||||||
else:
|
else:
|
||||||
send_chat(f"Cannot redeem {redeem}, no note included.")
|
send_chat(f"Cannot redeem {redeem}, no note included.")
|
||||||
send_chat(f"{redeem} redeemed for 60 points.")
|
send_chat(f"{redeem} redeemed for {price} points.")
|
||||||
else:
|
else:
|
||||||
send_chat(f"{redeem} not redeemed because of an error.")
|
send_chat(f"{redeem} not redeemed because of an error.")
|
||||||
else:
|
else:
|
||||||
send_chat(f"Can't redeem {redeem}, you don't have enough points.")
|
send_chat(f"Can't redeem {redeem}, you don't have enough points.")
|
||||||
else:
|
else:
|
||||||
send_chat("Can't redeem, redeem not found.")
|
send_chat("Can't redeem, redeem not found.")
|
||||||
return False
|
|
Loading…
Reference in New Issue