diff --git a/tlapbot/default_config.py b/tlapbot/default_config.py index f96f4ca..88553f4 100644 --- a/tlapbot/default_config.py +++ b/tlapbot/default_config.py @@ -4,4 +4,5 @@ OWNCAST_INSTANCE_URL='http://localhost:8080' POINTS_CYCLE_TIME=600 POINTS_AMOUNT_GIVEN=10 LIST_REDEEMS=False -GUNICORN=False \ No newline at end of file +GUNICORN=False +PREFIX='!' \ No newline at end of file diff --git a/tlapbot/owncast_webhooks.py b/tlapbot/owncast_webhooks.py index 7621252..b5a7a15 100644 --- a/tlapbot/owncast_webhooks.py +++ b/tlapbot/owncast_webhooks.py @@ -30,22 +30,23 @@ def owncast_webhook(): if data["eventData"]["user"]["authenticated"]: remove_duplicate_usernames(db, user_id, new_name) elif data["type"] == "CHAT": + prefix = current_app.config['PREFIX'] user_id = data["eventData"]["user"]["id"] display_name = data["eventData"]["user"]["displayName"] current_app.logger.debug(f'New chat message from {display_name}:') current_app.logger.debug(f'{data["eventData"]["body"]}') - if data["eventData"]["body"].startswith("!help"): + if data["eventData"]["body"].startswith(f"{prefix}help"): send_help() - elif data["eventData"]["body"].startswith("!points"): + elif data["eventData"]["body"].startswith(f"{prefix}points"): points = read_users_points(db, user_id) send_chat(f"{display_name}'s points: {points}") - elif data["eventData"]["body"].startswith("!name_update"): + elif data["eventData"]["body"].startswith(f"{prefix}name_update"): # Forces name update in case bot didn't catch the NAME_CHANGE # event. Also removes saved usernames from users with same name # if user is authenticated. change_display_name(db, user_id, display_name) if data["eventData"]["user"]["authenticated"]: remove_duplicate_usernames(db, user_id, display_name) - elif data["eventData"]["body"].startswith("!"): # TODO: make prefix configurable + elif data["eventData"]["body"].startswith(prefix): # TODO: make prefix configurable handle_redeem(data["eventData"]["body"], user_id) return data