Chat slash command chat.command@1

Generated at from openvibe-contracts v0.419.0 and openvibe-sdk v0.161.0.

Version
1.0.0
Owner
chat
Visibility
first-party
Status
active
Compatibility
backward
Schema
https://openvibe.network/contracts/chat/command.v1.json

chat.command@1: one command the OpenVibe.Chat composer offers. A registered command's name (one to 32 lowercase letters, digits, underscores or dashes, starting with a letter), a plain-sentence description of at most 100 characters, and its typed options in order; source says who registered it (builtin, app or actor) and application_id names the app or actor for a registration. Chat serves the built-in list at GET /api/chat/commands (query q filters by name) and an option's choices at GET /api/chat/commands/autocomplete, both behind the default-off CHAT_SLASH_COMMANDS_ENABLED switch. An execution still runs through the socket's authenticated command pipeline with the sender's own rights, so moderating commands keep the moderation checks; an unknown command is answered with a plain sentence.

Fields

FieldTypeRequiredDescriptionConstraints
namestringyes
  • pattern ^[a-z][a-z0-9_-]{0,31}$
descriptionstringyes
  • maxLength 100
optionshttps://openvibe.network/contracts/chat/command.v1.json#/$defs/optionyes
  • maxItems 25
sourceenum
  • one of "builtin", "app", "actor"
application_idstring | null
  • maxLength 128

Examples

From the contract's own test fixtures: valid ones validate, rejected ones must fail.

Valid: mute-with-choices
{
  "name": "mute",
  "description": "Mute a member for a while",
  "options": [
    {
      "name": "user",
      "description": "Member",
      "type": "user",
      "required": true
    },
    {
      "name": "seconds",
      "description": "Duration in seconds",
      "type": "integer",
      "required": false,
      "choices": [
        "60",
        "300",
        "900"
      ]
    }
  ],
  "source": "app",
  "application_id": "app_01J8Z3Q4R5S6T7V8W9X0Y1Z2A3"
}
Valid: shrug
{
  "name": "shrug",
  "description": "Send a shrug",
  "options": [
    {
      "name": "text",
      "description": "Optional message",
      "type": "string",
      "required": false
    }
  ],
  "source": "builtin"
}
Rejected: bad-name
{
  "name": "Shrug Now!",
  "description": "Send a shrug",
  "options": []
}
Rejected: no-options
{
  "name": "help",
  "description": "Show available commands"
}
Rejected: permission-field
{
  "name": "ban",
  "description": "Ban a member",
  "options": [],
  "permission": "moderate"
}
Rejected: unknown-option-type
{
  "name": "slow",
  "description": "Set slow mode",
  "options": [
    {
      "name": "seconds",
      "description": "Seconds between messages",
      "type": "float",
      "required": true
    }
  ]
}

Validate

const contracts = require('openvibe-contracts');
contracts.validate('chat.command@1', value);   // { valid, errors: [{ path, message }] }