Load config from $HROCHOBOT_ETC

This commit is contained in:
Martin Mareš 2023-04-16 18:51:12 +02:00
parent cdb06b320c
commit af563d8a2c

View file

@ -6,14 +6,15 @@ import os
data.DATA_FOLDER = os.environ.get("HROCHOBOT_DATA", 'data') data.DATA_FOLDER = os.environ.get("HROCHOBOT_DATA", 'data')
LOG_FOLDER = os.environ.get("HROCHOBOT_LOG", '.') LOG_FOLDER = os.environ.get("HROCHOBOT_LOG", '.')
CONFIG_FOLDER = os.environ.get("HROCHOBOT_ETC", '.')
logger = logging.getLogger('hrochobot') logger = logging.getLogger('hrochobot')
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
handler = logging.FileHandler(filename=f'{LOG_FOLDER}/hrochobot.log', encoding='utf-8', mode='w') handler = logging.FileHandler(filename=os.path.join(LOG_FOLDER, 'hrochobot.log'), encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler) logger.addHandler(handler)
CONFIG = data.load_json("config") CONFIG = data.load_json(os.path.join(CONFIG_FOLDER, "config"))
bot = commands.Bot() bot = commands.Bot()