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'
OWNCAST_ACCESS_TOKEN=''
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)
def give_points_to_chat(db):
points_given = 10
url = current_app.config['OWNCAST_INSTANCE_URL'] + '/api/integrations/clients'
headers = {"Authorization": "Bearer " + current_app.config['OWNCAST_ACCESS_TOKEN']}
r = requests.post(url, headers=headers)
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):
try:

View File

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