-
Notifications
You must be signed in to change notification settings - Fork 2
Config files and parameters
Rowboat's configuration can be found or created in config/config.yaml
. A very basic configuration file might look like this:
paths:
#Filesystem paths used by the core.
logger: "[logs/]Y-MM[.log]"
data: data/
environments:
#Environment declaration mapping each instance name to a map of options.
MyDiscord:
type: Discord
behaviorCommon:
#Common options that will be replicated to every loaded behavior.
Discord: MyDiscord
behaviors:
#Behavior declaration consisting in a list of behaviors in load order.
- Users
- Commands
The configuration file can be edited directly, but there are several command line arguments that can help you manipulate it. For a list, use:
node . --help
In the paths section, you'll find the template for Logger filenames - this is a moment.js template, with literals wrapped in [square brackets] - and the data path, where datastores are loaded and saved. Datastores are used by Behaviors for persisting data and use the JSON format.
The environments section is a map of environments you want to load. The type key is mandatory for each. All the other keys are parameters that are passed to the environment.
The behaviors section is a list of behaviors you want to load, in order. If the behavior is just a STRING
, it acts as an alias for type: STRING
; once again the type is mandatory. You can specify a custom instance name using the name key; otherwise the name will be the same as the type. Any other keys are parameters that are passed to the behavior.
behaviorCommon is a convenient map of parameters that are passed to every behavior you declare at the same time. Use this section for parameters that you know will have the same value everywhere.
In addition to config.yaml
, parameters for Environments and Behaviors can be set in independent files in the config folder. The following diagram shows where Rowboat will look for parameters and in what order.
It's recommended to use parameter files for setting parameters containing passwords, tokens and other credentials, so they can't be seen in the main configuration file and aren't accidentally leaked if the configuration file is shared.
In the example above, one could create mydiscord.env.yaml:
token: "..."
server: "..."
Add a new environment to your config file to make Rowboat connect to an additional service. The easiest way to do this is via command line. Start by checking which types are available:
node . --environmentTypes
If you want to learn more about an environment type, append it to the previous command. For example:
node . --environmentTypes Discord
Once you're ready to add the new environment, use --addEnvironment . You might also want to add comments that explain what they do to the config file:
node . --addEnvironment MyDiscord Discord --addEnvironmentComments MyDiscord
You can check if your environment is being loaded properly using:
node . --environments
Finish by filling in the configuration file.
Add a new behavior to your config file to make Rowboat do something new. Adding behaviors is very similar to adding environments (see above). To get a list of available behaviors:
node . --behaviorTypes
To learn more about a behavior type, append it to the command, such as in:
node . --behaviorTypes Google
Many behaviors may have dependencies - they require other behaviors or environments of certain types to be present in your application. Using the command above, you can see which parameters reference behaviors or environments and which types they must have. These references are always by instance name.
Once you're satisfied that you want to add your behavior, go ahead and use the equivalent of the command you used for the environment:
node . --addBehavior Google --addBehaviorComments Google
Because the Google behavior only supports a single instance, there's no need to specify the name and type separately; the name will default to the same as the type, "Google".
Check if your behavior is loading properly by using:
node . --behaviors
If there are required parameters, don't forget to fill them into the configuration file.