async-zulip-bot-sdk

Configuration

Configure bots via bots.yaml using Pydantic models AppConfig / BotConfig.

BotLocalConfig (per-bot settings)

Stored in bot.yaml (same directory as the bot module). Breaking change: class-level attributes are no longer read; configure everything here.

Fields (with defaults):

Example bot.yaml:

command_prefixes: ["!", "/"]
enable_mention_commands: true
auto_help_command: true
enable_storage: true
enable_orm: false
language: en
role_levels:
  user: 1
  moderator: 30
  admin: 50
  owner: 100
  bot_owner: 200
settings:
  custom_key: custom_value

After editing bot.yaml, use !reload (admin-level command) to reload settings and translations without restarting.

BotConfig (per bot in bots.yaml)

Fields:

StorageConfig

AppConfig (multiple bots)

bots.yaml example

bots:
  - name: dev_bot
    module: bots.dev_bot
    class_name: TranslatorBot
    enabled: true
    zuliprc: bots/dev_bot/zuliprc
    event_types: ["message"]
    storage:
      auto_cache: true
      auto_flush_interval: 5.0
      auto_flush_retry: 1.0
      auto_flush_max_retries: 3
    config:
      native_language_default: "en"

  - name: echo_bot
    module: bots.echo_bot
    class_name: EchoBot
    enabled: false  # disabled

Loading configuration

from bot_sdk.config import load_config, AppConfig

# You may load your other yaml files similarly
# Of course, define your own Pydantic models as needed
app_config = load_config("bots.yaml", AppConfig)
for bot_cfg in app_config.bots:
    if bot_cfg.enabled:
        print(bot_cfg.name, bot_cfg.storage)

Notes on migrations