mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 22:26:37 +00:00
refactor(slack): share channel config entry type
This commit is contained in:
@@ -19,6 +19,18 @@ export type SlackChannelConfigResolved = {
|
|||||||
matchSource?: ChannelMatchSource;
|
matchSource?: ChannelMatchSource;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type SlackChannelConfigEntry = {
|
||||||
|
enabled?: boolean;
|
||||||
|
allow?: boolean;
|
||||||
|
requireMention?: boolean;
|
||||||
|
allowBots?: boolean;
|
||||||
|
users?: Array<string | number>;
|
||||||
|
skills?: string[];
|
||||||
|
systemPrompt?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SlackChannelConfigEntries = Record<string, SlackChannelConfigEntry>;
|
||||||
|
|
||||||
function firstDefined<T>(...values: Array<T | undefined>) {
|
function firstDefined<T>(...values: Array<T | undefined>) {
|
||||||
for (const value of values) {
|
for (const value of values) {
|
||||||
if (typeof value !== "undefined") {
|
if (typeof value !== "undefined") {
|
||||||
@@ -74,18 +86,7 @@ export function resolveSlackChannelLabel(params: { channelId?: string; channelNa
|
|||||||
export function resolveSlackChannelConfig(params: {
|
export function resolveSlackChannelConfig(params: {
|
||||||
channelId: string;
|
channelId: string;
|
||||||
channelName?: string;
|
channelName?: string;
|
||||||
channels?: Record<
|
channels?: SlackChannelConfigEntries;
|
||||||
string,
|
|
||||||
{
|
|
||||||
enabled?: boolean;
|
|
||||||
allow?: boolean;
|
|
||||||
requireMention?: boolean;
|
|
||||||
allowBots?: boolean;
|
|
||||||
users?: Array<string | number>;
|
|
||||||
skills?: string[];
|
|
||||||
systemPrompt?: string;
|
|
||||||
}
|
|
||||||
>;
|
|
||||||
defaultRequireMention?: boolean;
|
defaultRequireMention?: boolean;
|
||||||
}): SlackChannelConfigResolved | null {
|
}): SlackChannelConfigResolved | null {
|
||||||
const { channelId, channelName, channels, defaultRequireMention } = params;
|
const { channelId, channelName, channels, defaultRequireMention } = params;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { OpenClawConfig, SlackReactionNotificationMode } from "../../config
|
|||||||
import type { DmPolicy, GroupPolicy } from "../../config/types.js";
|
import type { DmPolicy, GroupPolicy } from "../../config/types.js";
|
||||||
import type { RuntimeEnv } from "../../runtime.js";
|
import type { RuntimeEnv } from "../../runtime.js";
|
||||||
import type { SlackMessageEvent } from "../types.js";
|
import type { SlackMessageEvent } from "../types.js";
|
||||||
|
import type { SlackChannelConfigEntries } from "./channel-config.js";
|
||||||
import { formatAllowlistMatchMeta } from "../../channels/allowlist-match.js";
|
import { formatAllowlistMatchMeta } from "../../channels/allowlist-match.js";
|
||||||
import { resolveSessionKey, type SessionScope } from "../../config/sessions.js";
|
import { resolveSessionKey, type SessionScope } from "../../config/sessions.js";
|
||||||
import { logVerbose } from "../../globals.js";
|
import { logVerbose } from "../../globals.js";
|
||||||
@@ -70,18 +71,7 @@ export type SlackMonitorContext = {
|
|||||||
groupDmEnabled: boolean;
|
groupDmEnabled: boolean;
|
||||||
groupDmChannels: string[];
|
groupDmChannels: string[];
|
||||||
defaultRequireMention: boolean;
|
defaultRequireMention: boolean;
|
||||||
channelsConfig?: Record<
|
channelsConfig?: SlackChannelConfigEntries;
|
||||||
string,
|
|
||||||
{
|
|
||||||
enabled?: boolean;
|
|
||||||
allow?: boolean;
|
|
||||||
requireMention?: boolean;
|
|
||||||
allowBots?: boolean;
|
|
||||||
users?: Array<string | number>;
|
|
||||||
skills?: string[];
|
|
||||||
systemPrompt?: string;
|
|
||||||
}
|
|
||||||
>;
|
|
||||||
groupPolicy: GroupPolicy;
|
groupPolicy: GroupPolicy;
|
||||||
useAccessGroups: boolean;
|
useAccessGroups: boolean;
|
||||||
reactionMode: SlackReactionNotificationMode;
|
reactionMode: SlackReactionNotificationMode;
|
||||||
|
|||||||
Reference in New Issue
Block a user