Skip to content

Conversation

@JannisBush
Copy link
Contributor

Currently, redbot_cli uses a fixed config that is not easy to change.
The changes make redbot_cli use the same config file as the other services.


config_parser = ConfigParser()
config_parser.read_dict({"redbot": {"lang": "en", "charset": "utf-8"}})
config_parser.read(os.environ.get("REDBOT_CONFIG", "config.txt"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect it'd be better to use $XDG_CONFIG_HOME, defaulting to $HOME/.config as per the spec.

Something like:

Suggested change
config_parser.read(os.environ.get("REDBOT_CONFIG", "config.txt"))
home_dir = os.environ.get("HOME")
config_dir = os.environ.get("XDG_CONFIG_HOME", f"{home_dir}/.config")
config_loc = f"{config_dir}/redbot.cfg"
if os.path.exists(config_loc):
config_parser.read(config_loc)
else:
config_parser.read_dict({"redbot": {"lang": "en", "charset": "utf-8"}})

(not tested)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied how to read the config file from https://github.com/mnot/redbot/blob/main/bin/redbot_cgi.py#L82
I guess both ways are fine, but it is probably least confusing if all files use the same mechanism to read the config file.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redbot_cgi.py is no more, so that shouldn't be an issue any more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants