





















@@ -5,6 +5,7 @@ import { readJsonFileWithFallback } from "openclaw/plugin-sdk/json-store";
55import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
66import { normalizeTelegramBotInfo, type TelegramBotInfo } from "./bot-info.js";
77import { getTelegramRuntime } from "./runtime.js";
8+import { normalizeTelegramStateAccountId } from "./state-account-id.js";
89import { fingerprintTelegramBotToken } from "./token-fingerprint.js";
9101011const LEGACY_STORE_VERSION = 1;
@@ -31,14 +32,6 @@ type TelegramBotInfoCacheStore = {
31323233let botInfoCacheStoreForTest: TelegramBotInfoCacheStore | undefined;
333434-function normalizeAccountId(accountId?: string) {
35-const trimmed = accountId?.trim();
36-if (!trimmed) {
37-return "default";
38-}
39-return trimmed.replace(/[^a-z0-9._-]+/gi, "_");
40-}
41-4235function fingerprintFromToken(botToken?: string): string | null {
4336const trimmed = botToken?.trim();
4437if (!trimmed) {
@@ -52,7 +45,11 @@ export function resolveTelegramBotInfoCachePath(
5245env: NodeJS.ProcessEnv = process.env,
5346): string {
5447const stateDir = resolveStateDir(env, os.homedir);
55-return path.join(stateDir, "telegram", `bot-info-${normalizeAccountId(accountId)}.json`);
48+return path.join(
49+stateDir,
50+"telegram",
51+`bot-info-${normalizeTelegramStateAccountId(accountId)}.json`,
52+);
5653}
57545855function openBotInfoCacheStore(): TelegramBotInfoCacheStore {
@@ -110,7 +107,7 @@ export async function readCachedTelegramBotInfo(params: {
110107return null;
111108}
112109const parsed = parseCachedTelegramBotInfo(
113-await openBotInfoCacheStore().lookup(normalizeAccountId(params.accountId)),
110+await openBotInfoCacheStore().lookup(normalizeTelegramStateAccountId(params.accountId)),
114111);
115112if (!parsed || parsed.tokenFingerprint !== tokenFingerprint) {
116113return null;
@@ -136,15 +133,15 @@ export async function writeCachedTelegramBotInfo(params: {
136133if (!botInfo) {
137134return;
138135}
139-await openBotInfoCacheStore().register(normalizeAccountId(params.accountId), {
136+await openBotInfoCacheStore().register(normalizeTelegramStateAccountId(params.accountId), {
140137 tokenFingerprint,
141138fetchedAt: new Date().toISOString(),
142139 botInfo,
143140});
144141}
145142146143export async function deleteCachedTelegramBotInfo(params: { accountId?: string }): Promise<void> {
147-await openBotInfoCacheStore().delete(normalizeAccountId(params.accountId));
144+await openBotInfoCacheStore().delete(normalizeTelegramStateAccountId(params.accountId));
148145}
149146150147export function setTelegramBotInfoCacheStoreForTest(
@@ -162,5 +159,5 @@ export async function listTelegramLegacyBotInfoCacheEntries(params: {
162159if (!parsed) {
163160return [];
164161}
165-return [{ key: normalizeAccountId(params.accountId), value: parsed }];
162+return [{ key: normalizeTelegramStateAccountId(params.accountId), value: parsed }];
166163}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。