Made quote system and its dependencies optional
This commit is contained in:
parent
5e4c372d38
commit
a518dece04
|
@ -12,8 +12,8 @@ Code attributions can be found in `ATTRIBUTIONS.md`
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
* Install Flask and psycopg2
|
* Install Flask and (optionally for the quote system) psycopg2
|
||||||
* `pip --user install Flask 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
|
* 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
|
* 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
|
* http://localhost:5000/webhook/owncast if bot and owncast are on the same machine
|
||||||
|
|
|
@ -5,7 +5,6 @@ import requests
|
||||||
from requests.structures import CaseInsensitiveDict
|
from requests.structures import CaseInsensitiveDict
|
||||||
from ameliabot.init_logging import init_logging
|
from ameliabot.init_logging import init_logging
|
||||||
from ameliabot.logger import logging
|
from ameliabot.logger import logging
|
||||||
from ameliabot.quote import Quote
|
|
||||||
from flask import request
|
from flask import request
|
||||||
|
|
||||||
init_logging()
|
init_logging()
|
||||||
|
@ -21,6 +20,15 @@ except FileNotFoundError:
|
||||||
logging.error("Please see README.md for more information.")
|
logging.error("Please see README.md for more information.")
|
||||||
raise SystemExit
|
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:
|
with open("commands.json", "r") as f:
|
||||||
commands = json.load(f)
|
commands = json.load(f)
|
||||||
logging.info("Commands loaded")
|
logging.info("Commands loaded")
|
||||||
|
@ -29,12 +37,6 @@ with open("alias.json", "r") as f:
|
||||||
aliases = json.load(f)
|
aliases = json.load(f)
|
||||||
logging.info("Aliases loaded")
|
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
|
# prepare the header for the bot posts
|
||||||
headers = CaseInsensitiveDict()
|
headers = CaseInsensitiveDict()
|
||||||
headers["Content-Type"] = "application/json"
|
headers["Content-Type"] = "application/json"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
"owncast_server": "localhost",
|
"owncast_server": "localhost",
|
||||||
"access_token": "",
|
"access_token": "",
|
||||||
"streamer_name": "owncast streamer",
|
"streamer_name": "owncast streamer",
|
||||||
|
"quote_enabled": false,
|
||||||
"quote_db_name": "",
|
"quote_db_name": "",
|
||||||
"quote_db_user": "",
|
"quote_db_user": "",
|
||||||
"quote_db_pass": ""
|
"quote_db_pass": ""
|
||||||
|
|
Loading…
Reference in New Issue