archangelic / pinhook

the pluggable python framework for IRC bots and Twitch bots
https://archangelic.github.io/pinhook/
MIT License
31 stars 4 forks source link

Add persistent configuration into Bot #57

Open archangelic opened 5 years ago

archangelic commented 5 years ago

The bot needs persistent storage, but not enough to justify a database (see #51). I believe the solution is to have a config file passed to the Bot object that it can read and write to. This can also help in doing config-only init (#39)

So the only decision i need to make is to standardize the format for config:

Any thoughts?

ixxie commented 5 years ago

Well yaml is becoming increasingly standard for configuration files, which is a good reason to use it.

However, having the bot write to a configuration file seems a bit odd; normally configuration files are immutable, and tracked in a version control system. I have often wondered if it is possible to design a configuration system that simultaniously does both declarative and imperative configuration, but I don't think you would be interested in piloting such techniques with pinhook.

If I am right and this is undesirable, we should distinguish the usecases here:

Assuming you want to stick to one configuration language, you could for example have an immutable config.yaml which is committed to git, and a mutable state.yaml which is not committed to git, where the bot can write various stuff, like banned users.

archangelic commented 5 years ago

The thing is that config.yaml might have server, or channel passwords associated in it. May not be the best thing to keep in git repos.

Also a possibility is to add a small executable that can both create the config and start a bot based on the configuration file provided.

ixxie commented 5 years ago

Thats a good point.

One way to deal with this is a secrets.yaml, but this may be annoying to have so many files. One way to do this is to offer the possibility to either have one or multiple yaml files as configuration; in the many case you would deep merge the resulting dicts to produce the full configuration.

Even without version control, I would still not like config.yaml to be mutable by the bot, at least not with banned users as the list can get big.

archangelic commented 5 years ago

Totally agree at this point that mutable data should not be in the config. Going to continue discussion on that in #51.