{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Config",
  "description": "The schema for the config JSON used by twitch2ma",
  "definitions": {
    "sacn": {
      "description": "The sACN configuration for locking commands and parameters.",
      "type": "object",
      "properties": {
        "universe": {
          "description": "The sACN universe to listen to.",
          "type": "integer",
          "minimum": 1,
          "maximum": 64000
        },
        "channel": {
          "description": "The sACN channel to listen to.",
          "type": "integer",
          "minimum": 1,
          "maximum": 512
        }
      },
      "additionalProperties": false,
      "required": [
        "universe",
        "channel"
      ]
    }
  },
  "type": "object",
  "properties": {
    "timeout": {
      "description": "The cooldown time in seconds between the execution of any command (prevents flooding/spamming). Does not apply to moderators and channel owners.",
      "type": "integer",
      "minimum": 0
    },
    "ma": {
      "description": "GrandMA 2 telnet configuration",
      "type": "object",
      "properties": {
        "host": {
          "description": "The IP address of the desk to connect to.",
          "type": "string",
          "format": "ipv4"
        },
        "user": {
          "description": "The GrandMA 2 user to log in with.",
          "type": "string",
          "default": "administrator",
          "pattern": "^[a-zA-Z0-9]+$"
        },
        "password": {
          "description": "The password for the user defined in 'ma.user'.",
          "type": "string",
          "default": "admin",
          "pattern": "^[a-zA-Z0-9]+$"
        }
      },
      "additionalProperties": false,
      "required": [
        "host"
      ]
    },
    "twitch": {
      "description": "The config for the Twitch connection.",
      "type": "object",
      "properties": {
        "clientId": {
          "description": "The client ID obtained by Twitch.",
          "type": "string",
          "pattern": "^[a-zA-Z0-9]+$"
        },
        "accessToken": {
          "description": "The access token obtained by Twitch.",
          "type": "string",
          "pattern": "^[a-zA-Z0-9]+$"
        },
        "channel": {
          "description": "The Twitch channel the bot connects to.",
          "type": "string",
          "pattern": "^\\w+$"
        }
      },
      "additionalProperties": false,
      "required": [
        "clientId",
        "accessToken",
        "channel"
      ]
    },
    "sacn": {
      "description": "sACN specific configuration used for sACN locks.",
      "type": "object",
      "properties": {
        "lockMessage": {
          "description": "The message to be sent when viewers try to execute a command that is currently locked. '{command}' is replaced by the attempted command and parameter.",
          "type": "string",
          "default": "{command} is currently locked! Please wait!"
        },
        "interface": {
          "description": "The IP address of the interface twitch2ma is listening on.",
          "type": "string",
          "format": "ipv4"
        },
        "timeout": {
          "description": "Time until sACN is considered lost.",
          "type": "number",
          "minimum": 0.5,
          "default": 2.5
        }
      },
      "additionalProperties": false,
      "default": {
        "lockMessage": "{command} is currently locked! Please wait!",
        "timeout": 2.5
      }
    },
    "commands": {
      "description": "An array of commands the bot reacts to.",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "chatCommand": {
            "description": "The command viewers need to use in chat without '!'. The command 'lights' is reserved for viewer help. ",
            "type": "string",
            "pattern": "^((?!\\b[lL][iI][gG][hH][tT][sS]\\b)[a-zA-Z0-9-])+$"
          },
          "consoleCommand": {
            "description": "The command that gets executed on the desk.",
            "type": "string"
          },
          "message": {
            "description": "A message that is sent to Twitch chat when the command was executed on the desk. '{user}' is replaced by the user who issued the command, '{parameterList}' is replaced by a list of available parameters if any.",
            "type": "string"
          },
          "help": {
            "description": "A help message that is sent to Twitch when viewers run the command '!lights !<command>'. '{parameterList}' is replaced by a list of available parameters if any.",
            "type": "string"
          },
          "sacn": {
            "$ref": "#/definitions/sacn"
          },
          "parameters": {
            "description": "An array of parameters for each command so viewers can call '!<command> <parameter>'.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "parameter": {
                  "description": "The parameter to append to the command.",
                  "type": "string",
                  "pattern": "^[a-zA-Z0-9-]+$"
                },
                "consoleCommand": {
                  "description": "The command that gets executed on the desk when using the parameter.",
                  "type": "string"
                },
                "message": {
                  "description": "A message that is sent to Twitch chat when the parameter was executed on the desk. '{user}' gets replaced by the user who issued the command.",
                  "type": "string"
                },
                "sacn": {
                  "$ref": "#/definitions/sacn"
                }
              },
              "additionalProperties": false,
              "required": [
                "parameter",
                "consoleCommand"
              ]
            },
            "minItems": 1
          }
        },
        "additionalProperties": false,
        "required": [
          "chatCommand"
        ]
      }
    }
  },
  "additionalProperties": false,
  "required": [
    "timeout",
    "ma",
    "twitch",
    "commands"
  ]
}
