mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 19:18:26 +00:00
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { getChannelPlugin } from "../../channels/plugins/index.js";
|
|
import type { ChannelId, ChannelSetupInput } from "../../channels/plugins/types.js";
|
|
import type { OpenClawConfig } from "../../config/config.js";
|
|
import { normalizeAccountId } from "../../routing/session-key.js";
|
|
|
|
type ChatChannel = ChannelId;
|
|
|
|
export function applyAccountName(params: {
|
|
cfg: OpenClawConfig;
|
|
channel: ChatChannel;
|
|
accountId: string;
|
|
name?: string;
|
|
}): OpenClawConfig {
|
|
const accountId = normalizeAccountId(params.accountId);
|
|
const plugin = getChannelPlugin(params.channel);
|
|
const apply = plugin?.setup?.applyAccountName;
|
|
return apply ? apply({ cfg: params.cfg, accountId, name: params.name }) : params.cfg;
|
|
}
|
|
|
|
export function applyChannelAccountConfig(params: {
|
|
cfg: OpenClawConfig;
|
|
channel: ChatChannel;
|
|
accountId: string;
|
|
input: ChannelSetupInput;
|
|
}): OpenClawConfig {
|
|
const accountId = normalizeAccountId(params.accountId);
|
|
const plugin = getChannelPlugin(params.channel);
|
|
const apply = plugin?.setup?.applyAccountConfig;
|
|
if (!apply) {
|
|
return params.cfg;
|
|
}
|
|
return apply({ cfg: params.cfg, accountId, input: params.input });
|
|
}
|