{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://github.com/iocalebs/patrolbot/internal/config/config", "$ref": "#/$defs/Config", "$defs": { "Config": { "properties": { "discord": { "$ref": "#/$defs/Discord", "description": "Discord bot configuration" }, "log": { "$ref": "#/$defs/Log", "description": "Logging configuration" }, "server": { "$ref": "#/$defs/Server", "description": "HTTP server configuration" }, "userAgent": { "type": "string", "description": "User-Agent HTTP header for MediaWiki and Discord API requests\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/User-Agent" }, "wiki": { "type": "string", "description": "Target wiki for bot commands" }, "wikis": { "additionalProperties": { "$ref": "#/$defs/Wiki" }, "type": "object", "description": "Wiki configurations" } }, "additionalProperties": false, "type": "object", "required": [ "discord", "log", "userAgent", "wiki", "wikis" ], "description": "Config represents the configuration for PatrolBot." }, "Discord": { "properties": { "api": { "type": "string", "description": "API version URL, e.g. https://discord.com/api/v10\nSee: https://discord.com/developers/docs/reference#api-versioning" }, "appID": { "type": "string", "description": "Application ID" }, "publicKey": { "type": "string", "description": "Public key" }, "token": { "type": "string", "description": "Bot token" } }, "additionalProperties": false, "type": "object", "required": [ "api", "appID", "publicKey", "token" ], "description": "Discord represents the Discord bot configuration." }, "Duration": { "properties": { "hours": { "type": "integer", "minimum": 1 }, "days": { "type": "integer", "minimum": 1 }, "weeks": { "type": "integer", "minimum": 1 } }, "additionalProperties": false, "type": "object", "description": "Duration represents a span of time expressed in hours, days, or weeks." }, "Log": { "properties": { "level": { "type": "string", "enum": [ "DEBUG", "INFO", "WARN", "ERROR" ], "description": "Level is the minimum severity level that will be logged.", "default": "INFO" } }, "additionalProperties": false, "type": "object", "required": [ "level" ], "description": "Log represents PatrolBot logging configuration." }, "PatrolExpiring": { "properties": { "windows": { "items": { "$ref": "#/$defs/Duration" }, "type": "array", "description": "Durations of time before changes reach $wgRCMaxAge and expire from Special:RecentChanges." } }, "additionalProperties": false, "type": "object", "required": [ "windows" ], "description": "PatrolExpiring represents the configuration for the github.com/iocalebs/patrolbot/internal/report/data.PatrolExpiring data source." }, "ReportData": { "properties": { "patrolExpiring": { "$ref": "#/$defs/PatrolExpiring", "description": "Counts unpatrolled edits via API:RecentChanges" } }, "additionalProperties": false, "type": "object", "description": "ReportData represents the configuration for the data sources used for a report type." }, "ReportType": { "properties": { "template": { "type": "string", "description": "File name of the template to use for the report" }, "discordChannelID": { "type": "string", "description": "Discord channel to post the report to" }, "description": { "type": "string", "description": "Description of the report type in 100 characters or less" }, "data": { "$ref": "#/$defs/ReportData", "description": "Data to use in the report" } }, "additionalProperties": false, "type": "object", "required": [ "template", "discordChannelID", "description", "data" ], "description": "ReportType represents the configuration for a specific report type." }, "Reports": { "properties": { "templateDir": { "type": "string", "minLength": 1, "description": "Path to directory containing report templates" }, "discordServerID": { "type": "string", "description": "Discord server (guild) ID to post reports in" }, "types": { "additionalProperties": { "$ref": "#/$defs/ReportType" }, "type": "object", "description": "Defines the types of reports that can be generated using the `report` command" } }, "additionalProperties": false, "type": "object", "required": [ "templateDir", "discordServerID", "types" ], "description": "Reports represents the configuration for generating reports." }, "Server": { "properties": { "port": { "type": "integer", "description": "Port to listen on" }, "timeouts": { "$ref": "#/$defs/Timeouts", "description": "HTTP server timeouts as durations, e.g. \"2s\" or \"500ms\"\nSee: https://pkg.go.dev/net/http#Server" } }, "additionalProperties": false, "type": "object", "required": [ "port", "timeouts" ], "description": "Server represents the configuration for the PatrolBot HTTP server." }, "Timeouts": { "properties": { "readTimeout": { "type": "string" }, "readHeaderTimeout": { "type": "string" }, "writeTimeout": { "type": "string" }, "idleTimeout": { "type": "string" } }, "additionalProperties": false, "type": "object", "required": [ "readTimeout", "readHeaderTimeout", "writeTimeout", "idleTimeout" ], "description": "Timeouts represents the configuration for the PatrolBot HTTP server timeouts." }, "Wiki": { "properties": { "site": { "$ref": "#/$defs/WikiSite", "description": "MediaWiki site information that PatrolBot needs to be aware of." }, "auth": { "$ref": "#/$defs/WikiAuth", "description": "Authentication credentials for the MediaWiki API\nSee https://www.mediawiki.org/wiki/API:Login" }, "client": { "$ref": "#/$defs/WikiClient", "description": "Configuration for the HTTP client used for MediaWiki API requests." }, "reports": { "$ref": "#/$defs/Reports", "description": "Configuration for the wiki's reports" } }, "additionalProperties": false, "type": "object", "required": [ "site", "auth", "client", "reports" ], "description": "Wiki represents the configuration for a particular MediaWiki instance." }, "WikiAuth": { "properties": { "username": { "type": "string", "description": "Special:BotPasswords username (e.g. PhantomCaleb@PatrolBot)" }, "password": { "type": "string", "description": "Special:BotPasswords password" } }, "additionalProperties": false, "type": "object", "required": [ "username", "password" ], "description": "WikiAuth represents the configuration for the bot's MediaWiki API login credentials." }, "WikiClient": { "properties": { "timeout": { "type": "string", "minLength": 1, "description": "Request timeout as a string, e.g. \"2s\" or \"500ms\"\nA timeout of zero means no timeout" }, "from": { "type": "string", "description": "From HTTP header for API requests\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/From" } }, "additionalProperties": false, "type": "object", "required": [ "timeout", "from" ], "description": "WikiClient represents configuration for the HTTP client used for MediaWiki API requests." }, "WikiSite": { "properties": { "url": { "type": "string", "description": "Wiki URL (e.g. https://en.wikipedia.org)" }, "scriptPath": { "type": "string", "description": "Wiki script path - typically \"/w\"\nSee https://www.mediawiki.org/wiki/Manual:$wgScriptPath" }, "articlePath": { "type": "string", "description": "Wiki article path without /$1 ending - typically \"/wiki\"\nSee https://www.mediawiki.org/wiki/Manual:$wgArticlePath" }, "rcMaxAgeDays": { "type": "integer", "description": "The wiki's recent changes retention period in days\nSee https://www.mediawiki.org/wiki/Manual:$wgRCMaxAge" }, "rcLinkLimit": { "type": "integer", "description": "Maximum results that can be shown in the wikis' Special:RecentChanges\nSee https://www.mediawiki.org/wiki/Manual:$wgRCLinkLimits" } }, "additionalProperties": false, "type": "object", "required": [ "url", "scriptPath", "articlePath", "rcMaxAgeDays", "rcLinkLimit" ], "description": "WikiSite represents MediaWiki instance configuration (namely $wg variables) that PatrolBot needs to be aware of." } } }