Made quote system and its dependencies optional

This commit is contained in:
Siina Mashek 2022-04-19 14:12:27 +03:00
parent 5e4c372d38
commit a518dece04
3 changed files with 12 additions and 9 deletions

View File

@ -12,8 +12,8 @@ Code attributions can be found in `ATTRIBUTIONS.md`
## Setup
* Install Flask and psycopg2
* `pip --user install Flask psycopg2`
* Install Flask and (optionally for the quote system) psycopg2
* `pip --user install Flask`
* If you don't want to fiddle with psycopg2, you can install `python-psycopg2` from your distribution's package manager
* Create an Owncast webhook url pointing to your bot's location
* http://localhost:5000/webhook/owncast if bot and owncast are on the same machine

View File

@ -5,7 +5,6 @@ import requests
from requests.structures import CaseInsensitiveDict
from ameliabot.init_logging import init_logging
from ameliabot.logger import logging
from ameliabot.quote import Quote
from flask import request
init_logging()
@ -21,6 +20,15 @@ except FileNotFoundError:
logging.error("Please see README.md for more information.")
raise SystemExit
# Make quote system and dependencies optional
if config["quote_enabled"]:
from ameliabot.quote import Quote
quote = Quote(
database=config["quote_db_name"],
user=config["quote_db_user"],
password=config["quote_db_pass"],
)
with open("commands.json", "r") as f:
commands = json.load(f)
logging.info("Commands loaded")
@ -29,12 +37,6 @@ with open("alias.json", "r") as f:
aliases = json.load(f)
logging.info("Aliases loaded")
quote = Quote(
database=config["quote_db_name"],
user=config["quote_db_user"],
password=config["quote_db_pass"],
)
# prepare the header for the bot posts
headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/json"

View File

@ -2,6 +2,7 @@
"owncast_server": "localhost",
"access_token": "",
"streamer_name": "owncast streamer",
"quote_enabled": false,
"quote_db_name": "",
"quote_db_user": "",
"quote_db_pass": ""