mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-01 03:11:44 +00:00
refactor: rename clawdbot to moltbot with legacy compat
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { ClawdbotConfig } from "../../config/config.js";
|
||||
import type { MoltbotConfig } from "../../config/config.js";
|
||||
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../routing/session-key.js";
|
||||
|
||||
type ChannelSectionBase = {
|
||||
@@ -6,14 +6,14 @@ type ChannelSectionBase = {
|
||||
accounts?: Record<string, Record<string, unknown>>;
|
||||
};
|
||||
|
||||
function channelHasAccounts(cfg: ClawdbotConfig, channelKey: string): boolean {
|
||||
function channelHasAccounts(cfg: MoltbotConfig, channelKey: string): boolean {
|
||||
const channels = cfg.channels as Record<string, unknown> | undefined;
|
||||
const base = channels?.[channelKey] as ChannelSectionBase | undefined;
|
||||
return Boolean(base?.accounts && Object.keys(base.accounts).length > 0);
|
||||
}
|
||||
|
||||
function shouldStoreNameInAccounts(params: {
|
||||
cfg: ClawdbotConfig;
|
||||
cfg: MoltbotConfig;
|
||||
channelKey: string;
|
||||
accountId: string;
|
||||
alwaysUseAccounts?: boolean;
|
||||
@@ -24,12 +24,12 @@ function shouldStoreNameInAccounts(params: {
|
||||
}
|
||||
|
||||
export function applyAccountNameToChannelSection(params: {
|
||||
cfg: ClawdbotConfig;
|
||||
cfg: MoltbotConfig;
|
||||
channelKey: string;
|
||||
accountId: string;
|
||||
name?: string;
|
||||
alwaysUseAccounts?: boolean;
|
||||
}): ClawdbotConfig {
|
||||
}): MoltbotConfig {
|
||||
const trimmed = params.name?.trim();
|
||||
if (!trimmed) return params.cfg;
|
||||
const accountId = normalizeAccountId(params.accountId);
|
||||
@@ -54,7 +54,7 @@ export function applyAccountNameToChannelSection(params: {
|
||||
name: trimmed,
|
||||
},
|
||||
},
|
||||
} as ClawdbotConfig;
|
||||
} as MoltbotConfig;
|
||||
}
|
||||
const baseAccounts: Record<string, Record<string, unknown>> = base?.accounts ?? {};
|
||||
const existingAccount = baseAccounts[accountId] ?? {};
|
||||
@@ -77,14 +77,14 @@ export function applyAccountNameToChannelSection(params: {
|
||||
},
|
||||
},
|
||||
},
|
||||
} as ClawdbotConfig;
|
||||
} as MoltbotConfig;
|
||||
}
|
||||
|
||||
export function migrateBaseNameToDefaultAccount(params: {
|
||||
cfg: ClawdbotConfig;
|
||||
cfg: MoltbotConfig;
|
||||
channelKey: string;
|
||||
alwaysUseAccounts?: boolean;
|
||||
}): ClawdbotConfig {
|
||||
}): MoltbotConfig {
|
||||
if (params.alwaysUseAccounts) return params.cfg;
|
||||
const channels = params.cfg.channels as Record<string, unknown> | undefined;
|
||||
const base = channels?.[params.channelKey] as ChannelSectionBase | undefined;
|
||||
@@ -107,5 +107,5 @@ export function migrateBaseNameToDefaultAccount(params: {
|
||||
accounts,
|
||||
},
|
||||
},
|
||||
} as ClawdbotConfig;
|
||||
} as MoltbotConfig;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user