mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-20 18:55:00 +00:00
Register custom slash commands via Mattermost REST API at startup,
handle callbacks via HTTP endpoint on the gateway, and clean up
commands on shutdown.
- New modules: slash-commands.ts (API + registration), slash-http.ts
(callback handler), slash-state.ts (shared state bridge)
- Config schema extended with commands.{native,nativeSkills,callbackPath,callbackUrl}
- Uses oc_ prefix for triggers (oc_status, oc_model, etc.) to avoid
conflicts with Mattermost built-in commands
- Opt-in via channels.mattermost.commands.native: true
- Capability nativeCommands: true exposed for command registry
Closes openclaw/openclaw#16515
24 lines
866 B
TypeScript
24 lines
866 B
TypeScript
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
|
|
import { mattermostPlugin } from "./src/channel.js";
|
|
import { getSlashCommandState, registerSlashCommandRoute } from "./src/mattermost/slash-state.js";
|
|
import { setMattermostRuntime } from "./src/runtime.js";
|
|
|
|
const plugin = {
|
|
id: "mattermost",
|
|
name: "Mattermost",
|
|
description: "Mattermost channel plugin",
|
|
configSchema: emptyPluginConfigSchema(),
|
|
register(api: OpenClawPluginApi) {
|
|
setMattermostRuntime(api.runtime);
|
|
api.registerChannel({ plugin: mattermostPlugin });
|
|
|
|
// Register the HTTP route for slash command callbacks.
|
|
// The actual command registration with MM happens in the monitor
|
|
// after the bot connects and we know the team ID.
|
|
registerSlashCommandRoute(api);
|
|
},
|
|
};
|
|
|
|
export default plugin;
|