mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-06 09:22:31 -05:00
[Core V3] Make the bot data path configurable (#879)
* Initial commit * Fix sentry * Make cog manager install path work relative to the bot's dir * Fix downloader to save data relative to the defined data folder * Fix sentry test * Fix downloader tests * Change logfile location * Add another line to codeowners * Basic tests * Fix versioning * Add in FutureWarning for config file changes * Add reference to issue
This commit is contained in:
26
main.py
26
main.py
@@ -11,6 +11,7 @@ if discord.version_info.major < 1:
|
||||
|
||||
from core.bot import Red, ExitCodes
|
||||
from core.cog_manager import CogManagerUI
|
||||
from core.data_manager import load_basic_configuration
|
||||
from core.global_checks import init_global_checks
|
||||
from core.events import init_events
|
||||
from core.sentry_setup import init_sentry_logging
|
||||
@@ -22,6 +23,7 @@ import logging.handlers
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
from warnings import warn
|
||||
|
||||
#
|
||||
# Red - Discord Bot v3
|
||||
@@ -56,8 +58,10 @@ def init_loggers(cli_flags):
|
||||
else:
|
||||
logger.setLevel(logging.WARNING)
|
||||
|
||||
from core.data_manager import core_data_path
|
||||
logfile_path = core_data_path() / 'red.log'
|
||||
fhandler = logging.handlers.RotatingFileHandler(
|
||||
filename='red.log', encoding='utf-8', mode='a',
|
||||
filename=str(logfile_path), encoding='utf-8', mode='a',
|
||||
maxBytes=10**7, backupCount=5)
|
||||
fhandler.setFormatter(red_format)
|
||||
|
||||
@@ -88,6 +92,24 @@ async def _get_prefix_and_token(red, indict):
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli_flags = parse_cli_flags()
|
||||
|
||||
if cli_flags.config:
|
||||
load_basic_configuration(Path(cli_flags.config).resolve())
|
||||
else:
|
||||
warn("Soon you will need to change the way you load the bot."
|
||||
" The new method of loading has yet to be decided upon but"
|
||||
" will be made clear in announcements from the support server"
|
||||
" and from documentation. Please see issue #938 for further"
|
||||
" discussion on this topic.",
|
||||
category=FutureWarning)
|
||||
import core.data_manager
|
||||
defaults = core.data_manager.basic_config_default.copy()
|
||||
defaults['DATA_PATH'] = str(determine_main_folder())
|
||||
defaults['CORE_PATH_APPEND'] = 'core/.data'
|
||||
defaults['COG_PATH_APPEND'] = 'cogs/.data'
|
||||
|
||||
core.data_manager.basic_config = defaults
|
||||
|
||||
log, sentry_log = init_loggers(cli_flags)
|
||||
description = "Red v3 - Alpha"
|
||||
bot_dir = determine_main_folder()
|
||||
@@ -126,7 +148,7 @@ if __name__ == '__main__':
|
||||
loop.run_until_complete(_get_prefix_and_token(red, tmp_data))
|
||||
|
||||
if tmp_data['enable_sentry']:
|
||||
init_sentry_logging(sentry_log)
|
||||
init_sentry_logging(red, sentry_log)
|
||||
|
||||
cleanup_tasks = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user