Move all Slack channel implementation files from src/slack/ to extensions/slack/src/ and replace originals with shim re-exports. This follows the extension migration pattern for channel plugins. - Copy all .ts files to extensions/slack/src/ (preserving directory structure: monitor/, http/, monitor/events/, monitor/message-handler/) - Transform import paths: external src/ imports use relative paths back to src/, internal slack imports stay relative within extension - Replace all src/slack/ files with shim re-exports pointing to the extension copies - Update tsconfig.plugin-sdk.dts.json rootDir from "src" to "." so the DTS build can follow shim chains into extensions/ - Update write-plugin-sdk-entry-dts.ts re-export path accordingly - Preserve extensions/slack/index.ts, package.json, openclaw.plugin.json, src/channel.ts, src/runtime.ts, src/channel.test.ts (untouched)
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import type { SlackSlashCommandConfig } from "../../../../src/config/config.js";
|
|
|
|
/**
|
|
* Strip Slack mentions (<@U123>, <@U123|name>) so command detection works on
|
|
* normalized text. Use in both prepare and debounce gate for consistency.
|
|
*/
|
|
export function stripSlackMentionsForCommandDetection(text: string): string {
|
|
return (text ?? "")
|
|
.replace(/<@[^>]+>/g, " ")
|
|
.replace(/\s+/g, " ")
|
|
.trim();
|
|
}
|
|
|
|
export function normalizeSlackSlashCommandName(raw: string) {
|
|
return raw.replace(/^\/+/, "");
|
|
}
|
|
|
|
export function resolveSlackSlashCommandConfig(
|
|
raw?: SlackSlashCommandConfig,
|
|
): Required<SlackSlashCommandConfig> {
|
|
const normalizedName = normalizeSlackSlashCommandName(raw?.name?.trim() || "openclaw");
|
|
const name = normalizedName || "openclaw";
|
|
return {
|
|
enabled: raw?.enabled === true,
|
|
name,
|
|
sessionPrefix: raw?.sessionPrefix?.trim() || "slack:slash",
|
|
ephemeral: raw?.ephemeral !== false,
|
|
};
|
|
}
|
|
|
|
export function buildSlackSlashCommandMatcher(name: string) {
|
|
const normalized = normalizeSlackSlashCommandName(name);
|
|
const escaped = normalized.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
return new RegExp(`^/?${escaped}$`);
|
|
}
|