mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 15:49:40 +08:00
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
// Line plugin entrypoint registers its OpenClaw integration.
|
|
import {
|
|
defineBundledChannelEntry,
|
|
type OpenClawPluginCommandDefinition,
|
|
type OpenClawPluginApi,
|
|
} from "openclaw/plugin-sdk/channel-entry-contract";
|
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
|
|
type RegisteredLineCardCommand = OpenClawPluginCommandDefinition;
|
|
|
|
function createLineCardCommandLoader(api: OpenClawPluginApi) {
|
|
return createLazyRuntimeModule<RegisteredLineCardCommand>(async () => {
|
|
let registered: RegisteredLineCardCommand | null = null;
|
|
const { registerLineCardCommand } = await import("./src/card-command.js");
|
|
registerLineCardCommand({
|
|
...api,
|
|
registerCommand(command: RegisteredLineCardCommand) {
|
|
registered = command;
|
|
},
|
|
});
|
|
if (!registered) {
|
|
throw new Error("LINE card command registration unavailable");
|
|
}
|
|
return registered;
|
|
});
|
|
}
|
|
|
|
export default defineBundledChannelEntry({
|
|
id: "line",
|
|
name: "LINE",
|
|
description: "LINE Messaging API channel plugin",
|
|
importMetaUrl: import.meta.url,
|
|
plugin: {
|
|
specifier: "./channel-plugin-api.js",
|
|
exportName: "linePlugin",
|
|
},
|
|
runtime: {
|
|
specifier: "./runtime-api.js",
|
|
exportName: "setLineRuntime",
|
|
},
|
|
registerFull(api) {
|
|
const loadLineCardCommand = createLineCardCommandLoader(api);
|
|
api.registerCommand({
|
|
name: "card",
|
|
description: "Send a rich card message (LINE).",
|
|
acceptsArgs: true,
|
|
requireAuth: false,
|
|
async handler(ctx) {
|
|
const command = await loadLineCardCommand();
|
|
return await command.handler(ctx);
|
|
},
|
|
});
|
|
},
|
|
});
|