configurable points per X seconds implementation

This commit is contained in:
Lili (Tlapka) 2022-09-05 13:20:20 +02:00
parent aa7a53342f
commit c4fc1de95c
3 changed files with 7 additions and 5 deletions

View File

@ -2,4 +2,5 @@ SECRET_KEY='dev'
DATABASE='./instance/tlapbot.sqlite' DATABASE='./instance/tlapbot.sqlite'
OWNCAST_ACCESS_TOKEN='' OWNCAST_ACCESS_TOKEN=''
OWNCAST_INSTANCE_URL='http://localhost:8080' OWNCAST_INSTANCE_URL='http://localhost:8080'
POINTS_PER_10_MINUTES=10 POINTS_CYCLE_TIME=600
POINTS_AMOUNT_GIVEN=10

View File

@ -36,12 +36,13 @@ def use_points(db, user_id, points):
print("From user:", user_id, " amount of points:", points) print("From user:", user_id, " amount of points:", points)
def give_points_to_chat(db): def give_points_to_chat(db):
points_given = 10
url = current_app.config['OWNCAST_INSTANCE_URL'] + '/api/integrations/clients' url = current_app.config['OWNCAST_INSTANCE_URL'] + '/api/integrations/clients'
headers = {"Authorization": "Bearer " + current_app.config['OWNCAST_ACCESS_TOKEN']} headers = {"Authorization": "Bearer " + current_app.config['OWNCAST_ACCESS_TOKEN']}
r = requests.post(url, headers=headers) r = requests.post(url, headers=headers)
for user_object in r.json(): for user_object in r.json():
give_points_to_user(db, user_object["user"]["id"], points_given) give_points_to_user(db,
user_object["user"]["id"],
current_app.config['POINTS_AMOUNT_GIVEN'])
def user_exists(db, user_id): def user_exists(db, user_id):
try: try:

View File

@ -32,6 +32,6 @@ def owncast_webhook():
if points > 60: if points > 60:
use_points(db, user_id, 60) use_points(db, user_id, 60)
send_chat("Enjoy your DRINK........... sips") send_chat("Enjoy your DRINK........... sips")
else: # DEBUG: give points for message # else: # DEBUG: give points for message
give_points_to_chat(db) # give_points_to_chat(db)
return data return data