mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 02:50:23 +00:00
refactor: adopt shared account merge helpers
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { createAccountListHelpers } from "openclaw/plugin-sdk/account-helpers";
|
||||
import { createAccountListHelpers, mergeAccountConfig } from "openclaw/plugin-sdk/account-helpers";
|
||||
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
||||
import { parseOptionalDelimitedEntries } from "openclaw/plugin-sdk/core";
|
||||
import { tryReadSecretFileSync } from "openclaw/plugin-sdk/infra-runtime";
|
||||
@@ -60,19 +60,16 @@ function resolveAccountConfig(cfg: CoreConfig, accountId: string): IrcAccountCon
|
||||
}
|
||||
|
||||
function mergeIrcAccountConfig(cfg: CoreConfig, accountId: string): IrcAccountConfig {
|
||||
const {
|
||||
accounts: _ignored,
|
||||
defaultAccount: _ignoredDefaultAccount,
|
||||
...base
|
||||
} = (cfg.channels?.irc ?? {}) as IrcAccountConfig & {
|
||||
accounts?: unknown;
|
||||
defaultAccount?: unknown;
|
||||
};
|
||||
const account = resolveAccountConfig(cfg, accountId) ?? {};
|
||||
const merged: IrcAccountConfig = { ...base, ...account };
|
||||
if (base.nickserv || account.nickserv) {
|
||||
const merged: IrcAccountConfig = mergeAccountConfig<IrcAccountConfig>({
|
||||
channelConfig: cfg.channels?.irc as IrcAccountConfig | undefined,
|
||||
accountConfig: account,
|
||||
omitKeys: ["defaultAccount"],
|
||||
});
|
||||
const baseNickServ = (cfg.channels?.irc as IrcAccountConfig | undefined)?.nickserv;
|
||||
if (baseNickServ || account.nickserv) {
|
||||
merged.nickserv = {
|
||||
...base.nickserv,
|
||||
...baseNickServ,
|
||||
...account.nickserv,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user