UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

37 lines (36 loc) • 1.76 kB
import { c as normalizeOptionalLowercaseString, l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs"; import { b as uniqueStrings } from "./string-normalization-DLmfYZXI.mjs"; import { i as getLoadedChannelPluginForRead } from "./registry-loaded-NYWUyLLC.mjs"; import { t as normalizeAnyChannelId } from "./registry-normalize-guW5_4yo.mjs"; import "./registry-BB86xKJa.mjs"; import { i as stripTargetTopicSuffix, n as stripOutboundTargetKindPrefix, r as stripTargetProviderPrefix } from "./channel-target-prefix-tRLuyxKs.mjs"; //#region src/auto-reply/reply/group-id.ts /** Extracts a group/channel target id from explicit channel target syntax. */ function extractExplicitGroupId(e) { const t = normalizeOptionalString(e) ?? ""; if (!t) return; const n = t.split(":").filter(Boolean); const r = n.length >= 3 && (n[1] === "group" || n[1] === "channel") ? 2 : n.length >= 2 && (n[0] === "group" || n[0] === "channel") ? 1 : void 0; const i = r === void 0 ? void 0 : n.slice(r).join(":").replace(/:topic:.*$/, ""); if (i) return i; const a = n[0]; const o = normalizeAnyChannelId(a ?? "") ?? normalizeOptionalLowercaseString(a); const s = o ? getLoadedChannelPluginForRead(o)?.messaging : void 0; if (!o) return; const c = s?.normalizeTarget?.(t); const l = uniqueStrings([c, t].filter((e) => Boolean(e))); for (const e of l) { const t = s?.inferTargetChatType?.({ to: e }); if (t === "direct" || t == null) continue; const n = stripTargetTopicSuffix(stripOutboundTargetKindPrefix(stripTargetProviderPrefix(e, o), [ "group", "channel", "conversation", "room", "thread" ]), { allowNumericShorthand: s?.numericTopicShorthand === true }); if (n) return n; } } //#endregion export { extractExplicitGroupId as t };