add automatic point addition

This commit is contained in:
Lili (Tlapka) 2022-08-30 15:25:21 +02:00
parent f16f6cc925
commit d80ea74a29
1 changed files with 12 additions and 2 deletions

View File

@ -1,6 +1,8 @@
import os # for using paths in config import os
from flask import Flask from flask import Flask
from apscheduler.schedulers.background import BackgroundScheduler
from tlapbot.db import get_db
from tlapbot.owncast_helpers import give_points_to_chat
def create_app(test_config=None): def create_app(test_config=None):
app = Flask(__name__, instance_relative_config=True) app = Flask(__name__, instance_relative_config=True)
@ -18,6 +20,14 @@ def create_app(test_config=None):
app.register_blueprint(owncast_webhooks.bp) app.register_blueprint(owncast_webhooks.bp)
db.init_app(app) db.init_app(app)
def proxy_job():
with app.app_context():
give_points_to_chat(get_db())
points_giver = BackgroundScheduler()
points_giver.add_job(proxy_job, 'interval', seconds=10)
points_giver.start()
return app return app