add first implementation of redeem categories
This commit is contained in:
parent
2138650f91
commit
27812b9480
|
@ -3,8 +3,8 @@ import logging
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
from tlapbot.db import get_db
|
from tlapbot.db import get_db
|
||||||
from tlapbot.owncast_helpers import is_stream_live, give_points_to_chat
|
from tlapbot.owncast_helpers import (is_stream_live, give_points_to_chat,
|
||||||
|
remove_inactive_redeems)
|
||||||
|
|
||||||
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)
|
||||||
|
@ -24,6 +24,10 @@ def create_app(test_config=None):
|
||||||
app.config.from_object('tlapbot.default_redeems')
|
app.config.from_object('tlapbot.default_redeems')
|
||||||
app.config.from_pyfile('config.py', silent=True)
|
app.config.from_pyfile('config.py', silent=True)
|
||||||
app.config.from_pyfile('redeems.py', silent=True)
|
app.config.from_pyfile('redeems.py', silent=True)
|
||||||
|
app.config.from_mapping(
|
||||||
|
REDEEMS=remove_inactive_redeems(app.config['REDEEMS'],
|
||||||
|
app.config['ACTIVE_TYPES'])
|
||||||
|
)
|
||||||
|
|
||||||
# Make logging work for gunicorn-ran instances of tlapbot.
|
# Make logging work for gunicorn-ran instances of tlapbot.
|
||||||
if app.config['GUNICORN']:
|
if app.config['GUNICORN']:
|
||||||
|
|
|
@ -4,5 +4,6 @@ OWNCAST_INSTANCE_URL='http://localhost:8080'
|
||||||
POINTS_CYCLE_TIME=600
|
POINTS_CYCLE_TIME=600
|
||||||
POINTS_AMOUNT_GIVEN=10
|
POINTS_AMOUNT_GIVEN=10
|
||||||
LIST_REDEEMS=False
|
LIST_REDEEMS=False
|
||||||
|
ACTIVE_TYPES=[]
|
||||||
GUNICORN=False
|
GUNICORN=False
|
||||||
PREFIX='!'
|
PREFIX='!'
|
|
@ -235,5 +235,11 @@ def remove_emoji(message):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def remove_inactive_redeems(redeems):
|
def is_redeem_active(redeem, active_categories):
|
||||||
|
if "category" in redeem[1] and redeem[1]["category"] not in active_categories:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def remove_inactive_redeems(redeems, active_categories):
|
||||||
|
return dict(filter(lambda redeem: is_redeem_active(redeem, active_categories), redeems.items()))
|
Loading…
Reference in New Issue