Skip to content

Configuration

chrishayesmu edited this page May 11, 2016 · 8 revisions

Table of Contents

How it works

Configuration exists in one or more JSON files, which should be stored in the config/ directory (or any subdirectory) relative to your bot's directory root. You can define configuration both for DubBotBase, which will modify the framework's behavior, and for your own specific bot functionality.

You can spread out the config over as many files as you want, but if you write the same fully-qualified config key from multiple places, the value may be non-deterministic. Partially-qualified keys (i.e. namespaces) can be spread across multiple files without concern.

For example, the following files are acceptable:

{
    "DubBotBase": {
        "roomName": "myRoom"
    },
    "MyBotNamespace": {
        "MyCommand": {
            "key": "value"
        }
    }
}
{
    "DubBotBase": {
        "botEmail": "address@example.com",
        "botPassword": "password"
    },
    "MyBotNamespace": {
        "MyCommand": {
            "key2": "value2"
        }
    }
}

However, if you changed key2 to key in the second file, then when you tried to read that value at runtime, you might see either value or value2, based on which file happened to load first.

Framework-level keys

Each of these config keys is supported within the DubBotBase namespace, and can modify framework-level behavior.

areCommandsCaseSensitive

Data type Boolean
Default False

Controls whether or not user commands are case sensitive. If false, !command and !COMMAND both work the same, as do any mixed-case variants of the input. If true, the command entered in chat must exactly match the case of the trigger specified in the command code.

botEmail

Required Yes
Data type String

Sets the email address used by the bot to log in to dubtrack.fm. The application will not start without this value set. No validation is performed on this value to decide whether it looks like an email address, so double check it.

botPassword

Required Yes
Data type String

Sets the password used by the bot to log in to dubtrack.fm. The application will not start without this value set. Do not commit this to source control.

isConfigImmutable

Data type Boolean
Default True

Whether the config object ought to be frozen and made immutable after all of the configuration is read in. It's recommended to leave this as true unless you have good reason to change it (e.g., your bot exposes an interface for configuration at runtime). Making configuration immutable can make your application's behavior simpler to understand and debug.

logAllEvents

Data type Boolean
Default False

If set to true, DubBotBase will log raw input data for all of the events it sees, even events which aren't supported or recognized. This is mostly important for developing DubBotBase itself, but can be useful if you want to see which data from dubtrack.fm is available but not being sent to your application. You can submit a pull request or file an issue to have this data supported.

Note that you will still only see data for events supported by DubAPI, so it's not guaranteed you'll see everything possible here.

roomName

Required Yes
Data type String

The room that the bot will log into after booting up. If the URL to your room is https://dubtrack.fm/join/my-room, then the value here should be "my-room".