mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 18:35:48 +08:00
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import {
|
|
normalizeAccountId,
|
|
resolveAccountEntry,
|
|
type OpenClawConfig,
|
|
} from "openclaw/plugin-sdk/account-core";
|
|
import type { TelegramAccountConfig } from "openclaw/plugin-sdk/config-runtime";
|
|
|
|
export function resolveTelegramAccountConfig(
|
|
cfg: OpenClawConfig,
|
|
accountId: string,
|
|
): TelegramAccountConfig | undefined {
|
|
const normalized = normalizeAccountId(accountId);
|
|
return resolveAccountEntry(cfg.channels?.telegram?.accounts, normalized);
|
|
}
|
|
|
|
export function mergeTelegramAccountConfig(
|
|
cfg: OpenClawConfig,
|
|
accountId: string,
|
|
): TelegramAccountConfig {
|
|
const {
|
|
accounts: _ignored,
|
|
defaultAccount: _ignoredDefaultAccount,
|
|
groups: channelGroups,
|
|
...base
|
|
} = (cfg.channels?.telegram ?? {}) as TelegramAccountConfig & {
|
|
accounts?: unknown;
|
|
defaultAccount?: unknown;
|
|
};
|
|
const account = resolveTelegramAccountConfig(cfg, accountId) ?? {};
|
|
|
|
// Multi-account bots must not inherit channel-level groups unless explicitly set.
|
|
const configuredAccountIds = Object.keys(cfg.channels?.telegram?.accounts ?? {});
|
|
const isMultiAccount = configuredAccountIds.length > 1;
|
|
const groups = account.groups ?? (isMultiAccount ? undefined : channelGroups);
|
|
|
|
return { ...base, ...account, groups };
|
|
}
|