




















@@ -4,128 +4,27 @@ import {
44adaptScopedAccountAccessor,
55createScopedChannelConfigAdapter,
66} from "openclaw/plugin-sdk/channel-config-helpers";
7-import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input";
8-import { patchChannelConfigForAccount } from "openclaw/plugin-sdk/setup-runtime";
9-import { formatDocsLink } from "openclaw/plugin-sdk/setup-tools";
107import { inspectSlackAccount } from "./account-inspect.js";
118import {
129listSlackAccountIds,
1310resolveDefaultSlackAccountId,
1411resolveSlackAccount,
1512type ResolvedSlackAccount,
1613} from "./accounts.js";
17-import { getChatChannelMeta, type ChannelPlugin, type OpenClawConfig } from "./channel-api.js";
14+import { getChatChannelMeta, type ChannelPlugin } from "./channel-api.js";
1815import { SlackChannelConfigSchema } from "./config-schema.js";
1916import { slackDoctor } from "./doctor.js";
2017import { isSlackInteractiveRepliesEnabled } from "./interactive-replies.js";
2118import { collectRuntimeConfigAssignments, secretTargetRegistryEntries } from "./secret-contract.js";
2219import { slackSecurityAdapter } from "./security.js";
20+import { SLACK_CHANNEL } from "./setup-shared.js";
232124-export const SLACK_CHANNEL = "slack" as const;
25-26-function buildSlackManifest(botName: string) {
27-const safeName = botName.trim() || "OpenClaw";
28-const manifest = {
29-display_information: {
30-name: safeName,
31-description: `${safeName} connector for OpenClaw`,
32-},
33-features: {
34-bot_user: {
35-display_name: safeName,
36-always_online: true,
37-},
38-app_home: {
39-messages_tab_enabled: true,
40-messages_tab_read_only_enabled: false,
41-},
42-slash_commands: [
43-{
44-command: "/openclaw",
45-description: "Send a message to OpenClaw",
46-should_escape: false,
47-},
48-],
49-},
50-oauth_config: {
51-scopes: {
52-bot: [
53-"app_mentions:read",
54-"assistant:write",
55-"channels:history",
56-"channels:read",
57-"chat:write",
58-"commands",
59-"emoji:read",
60-"files:read",
61-"files:write",
62-"groups:history",
63-"groups:read",
64-"im:history",
65-"im:read",
66-"im:write",
67-"mpim:history",
68-"mpim:read",
69-"mpim:write",
70-"pins:read",
71-"pins:write",
72-"reactions:read",
73-"reactions:write",
74-"users:read",
75-],
76-},
77-},
78-settings: {
79-socket_mode_enabled: true,
80-event_subscriptions: {
81-bot_events: [
82-"app_mention",
83-"channel_rename",
84-"member_joined_channel",
85-"member_left_channel",
86-"message.channels",
87-"message.groups",
88-"message.im",
89-"message.mpim",
90-"pin_added",
91-"pin_removed",
92-"reaction_added",
93-"reaction_removed",
94-],
95-},
96-},
97-};
98-return JSON.stringify(manifest, null, 2);
99-}
100-101-export function buildSlackSetupLines(botName = "OpenClaw"): string[] {
102-return [
103-"1) Slack API -> Create App -> From scratch or From manifest (with the JSON below)",
104-"2) Add Socket Mode + enable it to get the app-level token (xapp-...)",
105-"3) Install App to workspace to get the xoxb- bot token",
106-"4) Enable Event Subscriptions (socket) for message events",
107-"5) App Home -> enable the Messages tab for DMs",
108-"Tip: set SLACK_BOT_TOKEN + SLACK_APP_TOKEN in your env.",
109-`Docs: ${formatDocsLink("/slack", "slack")}`,
110-"",
111-"Manifest (JSON):",
112-buildSlackManifest(botName),
113-];
114-}
115-116-export function setSlackChannelAllowlist(
117-cfg: OpenClawConfig,
118-accountId: string,
119-channelKeys: string[],
120-): OpenClawConfig {
121-const channels = Object.fromEntries(channelKeys.map((key) => [key, { enabled: true }]));
122-return patchChannelConfigForAccount({
123- cfg,
124-channel: SLACK_CHANNEL,
125- accountId,
126-patch: { channels },
127-});
128-}
22+export {
23+buildSlackSetupLines,
24+isSlackSetupAccountConfigured,
25+setSlackChannelAllowlist,
26+SLACK_CHANNEL,
27+} from "./setup-shared.js";
1292813029export function isSlackPluginAccountConfigured(account: ResolvedSlackAccount): boolean {
13130const mode = account.config.mode ?? "socket";
@@ -139,14 +38,6 @@ export function isSlackPluginAccountConfigured(account: ResolvedSlackAccount): b
13938return Boolean(account.appToken?.trim());
14039}
14140142-export function isSlackSetupAccountConfigured(account: ResolvedSlackAccount): boolean {
143-const hasConfiguredBotToken =
144-Boolean(account.botToken?.trim()) || hasConfiguredSecretInput(account.config.botToken);
145-const hasConfiguredAppToken =
146-Boolean(account.appToken?.trim()) || hasConfiguredSecretInput(account.config.appToken);
147-return hasConfiguredBotToken && hasConfiguredAppToken;
148-}
149-15041export const slackConfigAdapter = createScopedChannelConfigAdapter<ResolvedSlackAccount>({
15142sectionKey: SLACK_CHANNEL,
15243listAccountIds: listSlackAccountIds,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。