{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/donolink/json-schema/donolink-bot-update-schema.json",
  "title": "BotUpdate",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/donolink-openapi.json#/components/schemas/BotUpdate",
  "type": "object",
  "required": [
    "revision",
    "config"
  ],
  "properties": {
    "revision": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "config": {
      "$ref": "#/$defs/BotConfig"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "BotBuiltin": {
      "type": "object",
      "required": [
        "enabled",
        "role",
        "cooldownSeconds"
      ],
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "role": {
          "$ref": "#/$defs/BotRole"
        },
        "cooldownSeconds": {
          "type": "integer",
          "minimum": 5,
          "maximum": 86400
        },
        "userCooldownSeconds": {
          "type": "integer",
          "minimum": 0,
          "maximum": 86400,
          "description": "Optional per-viewer cooldown in seconds on top of the global cooldown. 0 disables it; omit the field entirely to remove it."
        }
      }
    },
    "BotCommand": {
      "type": "object",
      "required": [
        "id",
        "name",
        "message",
        "enabled",
        "role",
        "cooldownSeconds",
        "alias"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed.",
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "description": "Command name; normalized to lowercase. Letters, digits, underscore and hyphen, optionally starting with !."
        },
        "message": {
          "type": "string",
          "minLength": 0,
          "maxLength": 2000,
          "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed."
        },
        "enabled": {
          "type": "boolean"
        },
        "role": {
          "$ref": "#/$defs/BotRole"
        },
        "cooldownSeconds": {
          "type": "integer",
          "minimum": 5,
          "maximum": 86400
        },
        "userCooldownSeconds": {
          "type": "integer",
          "minimum": 0,
          "maximum": 86400,
          "description": "Optional per-viewer cooldown in seconds on top of the global cooldown. 0 disables it; omit the field entirely to remove it."
        },
        "alias": {
          "type": "string",
          "minLength": 0,
          "maxLength": 64,
          "description": "Empty or a command/builtin name. Target must exist; cycles and chains deeper than eight are rejected."
        }
      }
    },
    "BotConfig": {
      "type": "object",
      "required": [
        "version",
        "enabled",
        "commands",
        "timers",
        "filters",
        "blockedWords",
        "allowedHosts"
      ],
      "properties": {
        "version": {
          "const": 1
        },
        "enabled": {
          "type": "boolean"
        },
        "commands": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/BotCommand"
          },
          "maxItems": 500
        },
        "timers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/BotTimer"
          },
          "maxItems": 100
        },
        "filters": {
          "$ref": "#/$defs/BotFilters"
        },
        "blockedWords": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 0,
            "maxLength": 150,
            "description": "Plain entries are normalized (NFKC, lowercase) and match anywhere in the message. * is a wildcard that does not cross spaces (test* also blocks testing). Regex entries use ~/pattern/flags with flags from imsu only; patterns with nested quantifiers such as (a+)* are rejected."
          },
          "maxItems": 500
        },
        "allowedHosts": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 0,
            "maxLength": 253,
            "description": "Domain hostnames only, or blank lines which are removed. Lowercased; no scheme, port or path."
          },
          "maxItems": 200
        },
        "regulars": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/BotRegular"
          },
          "maxItems": 10000
        },
        "builtins": {
          "type": "object",
          "required": [],
          "properties": {
            "!permit": {
              "$ref": "#/$defs/BotBuiltin"
            },
            "!winner": {
              "$ref": "#/$defs/BotBuiltin"
            },
            "!commands": {
              "$ref": "#/$defs/BotBuiltin"
            },
            "!regulars": {
              "$ref": "#/$defs/BotBuiltin"
            },
            "!filters": {
              "$ref": "#/$defs/BotBuiltin"
            },
            "!poll": {
              "$ref": "#/$defs/BotBuiltin"
            },
            "!songs": {
              "$ref": "#/$defs/BotBuiltin"
            },
            "!title": {
              "$ref": "#/$defs/BotBuiltin"
            },
            "!game": {
              "$ref": "#/$defs/BotBuiltin"
            },
            "!tags": {
              "$ref": "#/$defs/BotBuiltin"
            },
            "!marker": {
              "$ref": "#/$defs/BotBuiltin"
            },
            "!commercial": {
              "$ref": "#/$defs/BotBuiltin"
            }
          }
        },
        "replyLanguage": {
          "type": "string",
          "enum": [
            "nl",
            "en",
            "de",
            "fr",
            "es",
            "it",
            "pl",
            "bg",
            "cs",
            "da",
            "fi",
            "el",
            "hu",
            "pt",
            "ro",
            "sv",
            "lt",
            "hr",
            "sk",
            "sl",
            "lv",
            "et",
            "mt"
          ],
          "default": "nl"
        }
      },
      "description": "Full owner configuration. Unknown config fields are discarded. Command IDs/names and timer IDs must be unique; regulars are unique per platform/userId. Omitted regulars/builtins default to empty. Templates may contain private data; do not publish or share-cache this response. Discord transport and external variables are not yet implemented."
    },
    "BotFilters": {
      "type": "object",
      "required": [
        "words",
        "caps",
        "emotes",
        "links",
        "symbols",
        "repetitions"
      ],
      "properties": {
        "words": {
          "type": "object",
          "required": [
            "enabled",
            "exemptRole",
            "timeoutSeconds",
            "silent",
            "message",
            "threshold",
            "minLength"
          ],
          "properties": {
            "enabled": {
              "type": "boolean"
            },
            "exemptRole": {
              "$ref": "#/$defs/BotRole"
            },
            "timeoutSeconds": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1209600
            },
            "silent": {
              "type": "boolean"
            },
            "message": {
              "type": "string",
              "minLength": 0,
              "maxLength": 450,
              "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed."
            },
            "threshold": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            },
            "minLength": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2000
            }
          }
        },
        "caps": {
          "type": "object",
          "required": [
            "enabled",
            "exemptRole",
            "timeoutSeconds",
            "silent",
            "message",
            "threshold",
            "minLength"
          ],
          "properties": {
            "enabled": {
              "type": "boolean"
            },
            "exemptRole": {
              "$ref": "#/$defs/BotRole"
            },
            "timeoutSeconds": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1209600
            },
            "silent": {
              "type": "boolean"
            },
            "message": {
              "type": "string",
              "minLength": 0,
              "maxLength": 450,
              "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed."
            },
            "threshold": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "minLength": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2000
            }
          }
        },
        "emotes": {
          "type": "object",
          "required": [
            "enabled",
            "exemptRole",
            "timeoutSeconds",
            "silent",
            "message",
            "threshold",
            "minLength"
          ],
          "properties": {
            "enabled": {
              "type": "boolean"
            },
            "exemptRole": {
              "$ref": "#/$defs/BotRole"
            },
            "timeoutSeconds": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1209600
            },
            "silent": {
              "type": "boolean"
            },
            "message": {
              "type": "string",
              "minLength": 0,
              "maxLength": 450,
              "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed."
            },
            "threshold": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            },
            "minLength": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2000
            }
          }
        },
        "links": {
          "type": "object",
          "required": [
            "enabled",
            "exemptRole",
            "timeoutSeconds",
            "silent",
            "message",
            "threshold",
            "minLength"
          ],
          "properties": {
            "enabled": {
              "type": "boolean"
            },
            "exemptRole": {
              "$ref": "#/$defs/BotRole"
            },
            "timeoutSeconds": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1209600
            },
            "silent": {
              "type": "boolean"
            },
            "message": {
              "type": "string",
              "minLength": 0,
              "maxLength": 450,
              "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed."
            },
            "threshold": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            },
            "minLength": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2000
            }
          }
        },
        "symbols": {
          "type": "object",
          "required": [
            "enabled",
            "exemptRole",
            "timeoutSeconds",
            "silent",
            "message",
            "threshold",
            "minLength"
          ],
          "properties": {
            "enabled": {
              "type": "boolean"
            },
            "exemptRole": {
              "$ref": "#/$defs/BotRole"
            },
            "timeoutSeconds": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1209600
            },
            "silent": {
              "type": "boolean"
            },
            "message": {
              "type": "string",
              "minLength": 0,
              "maxLength": 450,
              "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed."
            },
            "threshold": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "minLength": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2000
            }
          }
        },
        "repetitions": {
          "type": "object",
          "required": [
            "enabled",
            "exemptRole",
            "timeoutSeconds",
            "silent",
            "message",
            "threshold",
            "minLength"
          ],
          "properties": {
            "enabled": {
              "type": "boolean"
            },
            "exemptRole": {
              "$ref": "#/$defs/BotRole"
            },
            "timeoutSeconds": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1209600
            },
            "silent": {
              "type": "boolean"
            },
            "message": {
              "type": "string",
              "minLength": 0,
              "maxLength": 450,
              "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed."
            },
            "threshold": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            },
            "minLength": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2000
            }
          }
        }
      }
    },
    "BotRegular": {
      "type": "object",
      "required": [
        "platform",
        "userId",
        "userName"
      ],
      "properties": {
        "platform": {
          "type": "string",
          "enum": [
            "twitch",
            "youtube",
            "discord"
          ]
        },
        "userId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed.",
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "userName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed."
        }
      }
    },
    "BotRole": {
      "type": "string",
      "enum": [
        "everyone",
        "subscriber",
        "regular",
        "vip",
        "moderator",
        "admin",
        "owner"
      ]
    },
    "BotTimer": {
      "type": "object",
      "required": [
        "id",
        "name",
        "message",
        "enabled",
        "intervalSeconds",
        "minChatLines",
        "alias"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed.",
          "pattern": "^[a-zA-Z0-9_-]+$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80,
          "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed."
        },
        "message": {
          "type": "string",
          "minLength": 0,
          "maxLength": 2000,
          "description": "Trimmed on input. Control characters are rejected; tab, CR and LF are allowed."
        },
        "enabled": {
          "type": "boolean"
        },
        "intervalSeconds": {
          "type": "integer",
          "minimum": 60,
          "maximum": 86400
        },
        "minChatLines": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10000
        },
        "alias": {
          "type": "string",
          "minLength": 0,
          "maxLength": 64,
          "description": "Empty or a command/builtin name. Target must exist; cycles and chains deeper than eight are rejected."
        }
      }
    }
  }
}