Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework how the configuration of marvin is done #71

Open
mosbth opened this issue Oct 11, 2024 · 4 comments
Open

Rework how the configuration of marvin is done #71

mosbth opened this issue Oct 11, 2024 · 4 comments
Assignees

Comments

@mosbth
Copy link
Owner

mosbth commented Oct 11, 2024

We have two bot protocols, irc and discord. They need separate settings and perhaps they have some common settings.

Today each bot has its own configuration as a dictionary in each bot and that is merged with the external config file, if such exists at startup.

The bot should work, if possible, with the default hard coded settings. That is to avoid the need of actual creating a separate config file.

It should be easy to start marvin, like this.

marvin irc
marvin discord

Some generic options should be available, such as:

marvin --help
marvin --version

The default configuration file could be named marvin.json and it should be possible to use another config file using cli.

marvin --config marvin2.json irc

An example of the generic and default configuration file can be like this.

{
    "general": {
        "dirIncoming": "work/incoming",
        "dirDone": "work/done"
    },
    "irc": {
        "server": "127.0.0.1",
        "port": 6667,
        "channel": "marvin",
        "nick": "marvin",
        "realname": "Marvin The All Mighty",
        "ident": null
    },
    "discord": {
        "token": ""
    }
}

An alternative, or complement, to a json config file could be .env, if that for some reason seems suitable.

We could support environment variables (without env) if needed. That could be useful for example when dealing with secrets. Each bot can have its own support for various environment variables.For example the irc bot could have IDENT and the discord bot could have TOKEN.

In the existing irc configuration we also have items like irclogfile, irclogmax and lastfm which might be removed.

@mosbth mosbth self-assigned this Oct 11, 2024
@kh31d4r
Copy link
Contributor

kh31d4r commented Oct 11, 2024

i like the .env file (combined with environment variables) better than the json file.

@mosbth
Copy link
Owner Author

mosbth commented Oct 11, 2024

Ok, if moving on with dotenv, the config file would look something like this.

# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
#  * .env                contains default values for the environment variables needed by the app
#  * .env.local          uncommitted file with local overrides
#  * .env.$APP_ENV       committed environment-specific defaults
#  * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.

# General for any bot
DIR_INCOMING="work/incoming"
DIR_DONE="work/done"

# Bot irc specifics
IRC_SERVER="127.0.0.1"
IRC_PORT=6667
IRC_CHANNEL="marvin"
IRC_NICK="marvin"
IRC_REAL_NAME="Marvin The All Mighty"
IRC_IDENT=

# Bot discord specifics
DISCORD_TOKEN=

@kh31d4r
Copy link
Contributor

kh31d4r commented Oct 11, 2024

maybe we should prefix the "framework" related config with "MARVIN" or "BOT" or something, and in case we have config for plugins they can have the plugin name in uppercase as prefix?

@mosbth
Copy link
Owner Author

mosbth commented Oct 11, 2024

Sounds nice. All fine with me.

All and all, I guess/feel dotenv is better than json in many aspects for this configuration, so lets move on with that.

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

No branches or pull requests

2 participants