mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:31:23 +00:00
fix(telegram): clear offsets on token change
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import type { ChannelId, ChannelSetupInput } from "../../channels/plugins/types.js";
|
||||
import type { ChannelChoice } from "../onboard-types.js";
|
||||
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js";
|
||||
import { listChannelPluginCatalogEntries } from "../../channels/plugins/catalog.js";
|
||||
import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
|
||||
import type { ChannelId, ChannelSetupInput } from "../../channels/plugins/types.js";
|
||||
import { writeConfigFile, type OpenClawConfig } from "../../config/config.js";
|
||||
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../routing/session-key.js";
|
||||
import { defaultRuntime, type RuntimeEnv } from "../../runtime.js";
|
||||
import { resolveTelegramAccount } from "../../telegram/accounts.js";
|
||||
import { deleteTelegramUpdateOffset } from "../../telegram/update-offset-store.js";
|
||||
import { createClackPrompter } from "../../wizard/clack-prompter.js";
|
||||
import { setupChannels } from "../onboard-channels.js";
|
||||
import type { ChannelChoice } from "../onboard-types.js";
|
||||
import {
|
||||
ensureOnboardingPluginInstalled,
|
||||
reloadOnboardingPluginRegistry,
|
||||
@@ -209,6 +211,11 @@ export async function channelsAddCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
const previousTelegramToken =
|
||||
channel === "telegram"
|
||||
? resolveTelegramAccount({ cfg: nextConfig, accountId }).token.trim()
|
||||
: "";
|
||||
|
||||
nextConfig = applyChannelAccountConfig({
|
||||
cfg: nextConfig,
|
||||
channel,
|
||||
@@ -216,6 +223,14 @@ export async function channelsAddCommand(
|
||||
input,
|
||||
});
|
||||
|
||||
if (channel === "telegram") {
|
||||
const nextTelegramToken = resolveTelegramAccount({ cfg: nextConfig, accountId }).token.trim();
|
||||
if (previousTelegramToken !== nextTelegramToken) {
|
||||
// Clear stale polling offsets after Telegram token rotation.
|
||||
await deleteTelegramUpdateOffset({ accountId });
|
||||
}
|
||||
}
|
||||
|
||||
await writeConfigFile(nextConfig);
|
||||
runtime.log(`Added ${channelLabel(channel)} account "${accountId}".`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user