mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 00:08:28 +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 type { TelegramAccountConfig } from "../config/types.js";
|
||||
import { isTruthyEnvValue } from "../infra/env.js";
|
||||
import { listBoundAccountIds, resolveDefaultAgentBoundAccountId } from "../routing/bindings.js";
|
||||
@@ -20,7 +20,7 @@ export type ResolvedTelegramAccount = {
|
||||
config: TelegramAccountConfig;
|
||||
};
|
||||
|
||||
function listConfiguredAccountIds(cfg: ClawdbotConfig): string[] {
|
||||
function listConfiguredAccountIds(cfg: MoltbotConfig): string[] {
|
||||
const accounts = cfg.channels?.telegram?.accounts;
|
||||
if (!accounts || typeof accounts !== "object") return [];
|
||||
const ids = new Set<string>();
|
||||
@@ -31,7 +31,7 @@ function listConfiguredAccountIds(cfg: ClawdbotConfig): string[] {
|
||||
return [...ids];
|
||||
}
|
||||
|
||||
export function listTelegramAccountIds(cfg: ClawdbotConfig): string[] {
|
||||
export function listTelegramAccountIds(cfg: MoltbotConfig): string[] {
|
||||
const ids = Array.from(
|
||||
new Set([...listConfiguredAccountIds(cfg), ...listBoundAccountIds(cfg, "telegram")]),
|
||||
);
|
||||
@@ -40,7 +40,7 @@ export function listTelegramAccountIds(cfg: ClawdbotConfig): string[] {
|
||||
return ids.sort((a, b) => a.localeCompare(b));
|
||||
}
|
||||
|
||||
export function resolveDefaultTelegramAccountId(cfg: ClawdbotConfig): string {
|
||||
export function resolveDefaultTelegramAccountId(cfg: MoltbotConfig): string {
|
||||
const boundDefault = resolveDefaultAgentBoundAccountId(cfg, "telegram");
|
||||
if (boundDefault) return boundDefault;
|
||||
const ids = listTelegramAccountIds(cfg);
|
||||
@@ -49,7 +49,7 @@ export function resolveDefaultTelegramAccountId(cfg: ClawdbotConfig): string {
|
||||
}
|
||||
|
||||
function resolveAccountConfig(
|
||||
cfg: ClawdbotConfig,
|
||||
cfg: MoltbotConfig,
|
||||
accountId: string,
|
||||
): TelegramAccountConfig | undefined {
|
||||
const accounts = cfg.channels?.telegram?.accounts;
|
||||
@@ -61,7 +61,7 @@ function resolveAccountConfig(
|
||||
return matchKey ? (accounts[matchKey] as TelegramAccountConfig | undefined) : undefined;
|
||||
}
|
||||
|
||||
function mergeTelegramAccountConfig(cfg: ClawdbotConfig, accountId: string): TelegramAccountConfig {
|
||||
function mergeTelegramAccountConfig(cfg: MoltbotConfig, accountId: string): TelegramAccountConfig {
|
||||
const { accounts: _ignored, ...base } = (cfg.channels?.telegram ??
|
||||
{}) as TelegramAccountConfig & { accounts?: unknown };
|
||||
const account = resolveAccountConfig(cfg, accountId) ?? {};
|
||||
@@ -69,7 +69,7 @@ function mergeTelegramAccountConfig(cfg: ClawdbotConfig, accountId: string): Tel
|
||||
}
|
||||
|
||||
export function resolveTelegramAccount(params: {
|
||||
cfg: ClawdbotConfig;
|
||||
cfg: MoltbotConfig;
|
||||
accountId?: string | null;
|
||||
}): ResolvedTelegramAccount {
|
||||
const hasExplicitAccountId = Boolean(params.accountId?.trim());
|
||||
@@ -110,7 +110,7 @@ export function resolveTelegramAccount(params: {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
export function listEnabledTelegramAccounts(cfg: ClawdbotConfig): ResolvedTelegramAccount[] {
|
||||
export function listEnabledTelegramAccounts(cfg: MoltbotConfig): ResolvedTelegramAccount[] {
|
||||
return listTelegramAccountIds(cfg)
|
||||
.map((accountId) => resolveTelegramAccount({ cfg, accountId }))
|
||||
.filter((account) => account.enabled);
|
||||
|
||||
Reference in New Issue
Block a user