Docs contents

Plugin settings

Declare settings, and the WebUI builds the form for you.

Plugins often need settings that users fill in for their own setup: an API key, a polling interval, the groups to watch… Put a _conf_schema.json in the plugin folder, and a matching form appears in the plugin's settings in the WebUI.

ShiritaiBot's plugin settings use the same format as AstrBot. If you're moving a plugin from AstrBot to ShiritaiBot, you can copy its JSON as it is.

Declare settings

_conf_schema.json
{
  "api_key": {
    "type": "secret",
    "description": "API Key",
    "hint": "Get it from the weather service's console",
    "secret": true
  },
  "default_city": {
    "type": "string",
    "description": "Default city",
    "default": "London"
  },
  "unit": {
    "type": "string",
    "description": "Temperature unit",
    "options": ["c", "f"],
    "labels": ["Celsius", "Fahrenheit"],
    "default": "c"
  },
  "interval": {
    "type": "int",
    "description": "Refresh interval (seconds)",
    "slider": { "min": 60, "max": 3600, "step": 60 },
    "default": 600
  }
}

Each key is a setting's name, and its value describes the setting. The most common fields are type, description, hint and default, which set the setting's type, label, help text and default value.

Labels and help text can be given in each language, such as "description": {"zh-CN": "默认城市", "en": "Default city"}; see Languages.

Setting types

typeDescriptionDefault when default isn't set
stringOne line of text""
textSeveral lines of text""
intWhole number0
floatDecimal number0.0
boolSwitchfalse
listList of strings[]
objectA group of sub-settings, declared with itemsEach sub-setting's default
dictFree-form key-value pairs{}
template_listA list of entries added from templates[]

Here's how to write an object field:

_conf_schema.json
{
  "advanced": {
    "type": "object",
    "description": "Advanced settings",
    "items": {
      "retries": { "type": "int", "description": "Retries", "default": 3 },
      "verbose": { "type": "bool", "description": "Verbose logging" }
    }
  }
}

To read retries, use self.config["advanced"]["retries"] (see below).

Common options

OptionDescription
descriptionThe label shown on the form
hintHelp text under the label; add "obvious_hint": true to make it stand out
defaultThe default value
options / labels / subtitlesDropdown choices, their display names and their descriptions, matched up in order. A list with options becomes a multi-select
sliderAdds a slider to an int / float: {"min": 0, "max": 10, "step": 1}
secretA secret field; see below
invisibleNot shown on the form, but its value is kept; useful for data the plugin maintains itself
editor_mode / editor_languageShows a code editor, for JSON, regular expressions and the like
minimum / maximum / patternRange and regular-expression checks; when a value fails them, the plugin doesn't load

template_schema for dict and templates for template_list work as in AstrBot. The file type isn't supported yet.

Read settings

self.config is a dict of the defaults merged with the values the user entered:

main.py
class Weather(Plugin):
    async def initialize(self):
        self.city = self.config["default_city"]
        self.interval = self.config["interval"]

When the user saves the settings in the WebUI, the plugin reloads automatically and the new instance gets the new settings. So reading them in initialize() is enough; you don't need to watch for changes.

If the settings don't fit their definition (exceeding maximum, for example), the plugin doesn't load, and the plugin list shows which field is wrong.

Secret fields

Fields with "secret": true (only for string or list) are stored encrypted, and the WebUI never shows a saved value.

What the plugin reads isn't the plain value but a reference like secret:.... Turn it into the real value with resolve_secret():

main.py
async def initialize(self):
    self.api_key = await self.context.resolve_secret(self.config["api_key"])

Once you have the plain value, use it only inside the plugin: don't log it, don't return it to the model, and don't put it in a subprocess's environment.

Change settings from code

A plugin can change its own settings and save them:

main.py
self.config["last_sync"] = "2026-11-03T09:00:00+08:00"
await self.config.save_config()

save_config() only saves; it doesn't reload the plugin, and the current instance keeps using this self.config object.

For data produced while running, rather than settings the user needs to see or change, KV storage is a better fit.

Update your settings

When you upgrade a plugin, just edit _conf_schema.json. After a reload, new settings get their defaults, removed ones are dropped, and the values the user already entered stay as they are.