From 464350079ce3c4f12d7535322a8f16689feeb8dd Mon Sep 17 00:00:00 2001 From: Thor Harald Johansen Date: Mon, 19 Jul 2021 08:42:41 +0200 Subject: [PATCH] Defaults for all config options --- config.example.toml | 19 ++++++++++--------- cringebot.py | 12 ++++++++++-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/config.example.toml b/config.example.toml index b017c26..a23dfad 100644 --- a/config.example.toml +++ b/config.example.toml @@ -1,23 +1,24 @@ -name = "cringebot" +# Log name +#name = "cringebot" + +# Enable OCR support for image attachments +#ocr = false [defaults] # Name of the application as listed in the account settings on the server -app_name = "Cringebot" +#app_name = "Cringebot" # Minimum seconds between requests to the server -rate_limit = 3 +#rate_limit = 3 # Seconds between retrying failed requests to the server -retry_rate = 60 +#retry_rate = 60 # Seconds between polling the server for updates -poll_interval = 15 +#poll_interval = 15 # Minutes until cringe statuses are deleted -max_age = 600 - -# Enable OCR support for image attachments -#ocr = false +#max_age = 600 [clients] # The client name (in quotes below) is displayed in log messages, and is diff --git a/cringebot.py b/cringebot.py index e652205..3388b63 100644 --- a/cringebot.py +++ b/cringebot.py @@ -12,9 +12,12 @@ import html2text import urllib config_path = os.path.join(os.path.dirname(sys.argv[0]), "config.toml") -loaded_config = toml.load(config_path) +loaded_config = { + "name": "cringebot", + "ocr": False, + **toml.load(config_path)} -OCR = loaded_config.get("ocr", False) +OCR = loaded_config["ocr"] if OCR: from PIL import Image @@ -40,6 +43,11 @@ TIME_OF_DAY = { class CringeBotClient(BotClient): def __init__(self, bot, config): config = { + "app_name": "Cringebot", + "rate_limit": 3, + "retry_rate": 60, + "poll_interval": 15, + "max_age": 600, "db_dir": ".", "cringe_dir": "data/cringe", "based_dir": "data/based",