





























@@ -112,36 +112,64 @@ function detectTelegramBotInfoCacheLegacyStateMigration(params: {
112112});
113113}
114114115+function topicNameCacheImportSource(params: {
116+sourceStorePath: string;
117+targetStorePath?: string;
118+}): { sourcePath: string; namespace: string } {
119+const targetStorePath = params.targetStorePath ?? params.sourceStorePath;
120+const scope = resolveTopicNameCacheScope(targetStorePath);
121+return {
122+sourcePath: resolveTopicNameCachePath(params.sourceStorePath),
123+namespace: resolveTopicNameCacheNamespace(scope),
124+};
125+}
126+115127function detectTelegramTopicNameCacheLegacyStateMigration(params: {
116128cfg: OpenClawConfig;
117129env: NodeJS.ProcessEnv;
118130stateDir?: string;
119131}): ChannelLegacyStateMigrationPlan[] {
120-const storePath = resolveStorePath(params.cfg.session?.store, { env: params.env });
121-const runtimePersistedPath = resolveTopicNameCachePath(storePath);
132+const accountSources = listTelegramAccountIds(params.cfg).map((accountId) => {
133+const storePath = resolveStorePath(params.cfg.session?.store, {
134+env: params.env,
135+agentId: accountId,
136+});
137+return topicNameCacheImportSource({ sourceStorePath: storePath });
138+});
139+const defaultStorePath = resolveStorePath(params.cfg.session?.store, { env: params.env });
140+const defaultAccountStorePath = resolveStorePath(params.cfg.session?.store, {
141+env: params.env,
142+agentId: resolveDefaultTelegramAccountId(params.cfg),
143+});
122144const legacyStorePath = resolveLegacySessionStorePath(params);
123-const legacyPersistedPath = resolveTopicNameCachePath(legacyStorePath);
124-const scope = resolveTopicNameCacheScope(storePath);
125-const namespace = resolveTopicNameCacheNamespace(scope);
126-const sourcePaths = Array.from(new Set([runtimePersistedPath, legacyPersistedPath]));
127-return sourcePaths.flatMap((persistedPath) => {
128-if (!fileExists(persistedPath)) {
145+const sourcesByKey = new Map(
146+[
147+ ...accountSources,
148+topicNameCacheImportSource({ sourceStorePath: defaultStorePath }),
149+topicNameCacheImportSource({
150+sourceStorePath: legacyStorePath,
151+targetStorePath: defaultAccountStorePath,
152+}),
153+].map((source) => [`${source.sourcePath}\0${source.namespace}`, source] as const),
154+);
155+return [...sourcesByKey.values()].flatMap((source) => {
156+if (!fileExists(source.sourcePath)) {
129157return [];
130158}
131159return {
132160kind: "plugin-state-import",
133161label: "Telegram forum topic-name cache",
134-sourcePath: persistedPath,
135-targetPath: `plugin state:${namespace}`,
162+sourcePath: source.sourcePath,
163+targetPath: `plugin state:${source.namespace}`,
136164pluginId: "telegram",
137- namespace,
165+namespace: source.namespace,
138166maxEntries: TELEGRAM_TOPIC_NAME_CACHE_MAX_ENTRIES,
139167scopeKey: "",
140168cleanupSource: "rename",
141-preview: `- Telegram forum topic-name cache: ${persistedPath} → plugin state (${namespace})`,
169+preview: `- Telegram forum topic-name cache: ${source.sourcePath} → plugin state (${source.namespace})`,
142170readEntries: () => {
143171return listTelegramLegacyTopicNameCacheEntries({
144- persistedPath,
172+persistedPath: source.sourcePath,
145173maxEntries: TELEGRAM_TOPIC_NAME_CACHE_MAX_ENTRIES,
146174});
147175},
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。