import type { SlackEventMiddlewareArgs } from "@slack/bolt"; import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; import { enqueueSystemEvent } from "openclaw/plugin-sdk/infra-runtime"; import { danger } from "openclaw/plugin-sdk/runtime-env"; import type { SlackAppMentionEvent, SlackMessageEvent } from "../../types.js"; import { normalizeSlackChannelType } from "../channel-type.js"; import type { SlackMonitorContext } from "../context.js"; import type { SlackMessageHandler } from "../message-handler.js"; import type { SlackMessageChangedEvent } from "../types.js"; import { resolveSlackMessageSubtypeHandler } from "./message-subtype-handlers.js"; import { authorizeAndResolveSlackSystemEventContext } from "./system-event-context.js";
// NOTE: Slack Event Subscriptions use names like "message.channels" and // "message.groups" to control *which* message events are delivered, but the // actual event payload always arrives with `type: "message"`. The // `channel_type` field ("channel" | "group" | "im" | "mpim") distinguishes // the source. Bolt rejects `app.event("message.channels")` since v4.6 // because it is a subscription label, not a valid event type.
ctx.app.event("message", async ({ event, body }: SlackEventMiddlewareArgs<"message">) => {
await handleIncomingMessageEvent({ event, body });
});
ctx.app.event("app_mention", async ({ event, body }: SlackEventMiddlewareArgs<"app_mention">) => { try { if (ctx.shouldDropMismatchedSlackEvent(body)) { return;
}
const mention = event as SlackAppMentionEvent;
// Skip app_mention for DMs - they're already handled by message.im event // This prevents duplicate processing when both message and app_mention fire for DMs const channelType = normalizeSlackChannelType(mention.channel_type, mention.channel); if (channelType === "im" || channelType === "mpim") { return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.