Files
openclaw/src/telegram/bot-native-commands.test-helpers.ts
Ayaan Zaidi 9e1de97a69 fix(telegram): route native topic commands to the active session (#38871)
* fix(telegram): resolve session entry for /stop in forum topics

Fixes #38675

- Export normalizeStoreSessionKey from store.ts for reuse
- Use it in resolveSessionEntryForKey so topic session keys (lowercase
  in store) are found when handling /stop
- Add test for forum topic session key lookup

* fix(telegram): share native topic routing with inbound messages

* fix: land telegram topic routing follow-up (#38871)

---------

Co-authored-by: xialonglee <li.xialong@xydigit.com>
2026-03-07 19:01:16 +05:30

50 lines
1.9 KiB
TypeScript

import type { OpenClawConfig } from "../config/config.js";
import type { TelegramAccountConfig } from "../config/types.js";
import type { RuntimeEnv } from "../runtime.js";
import type { registerTelegramNativeCommands } from "./bot-native-commands.js";
type RegisterTelegramNativeCommandParams = Parameters<typeof registerTelegramNativeCommands>[0];
export function createNativeCommandTestParams(params: {
bot: RegisterTelegramNativeCommandParams["bot"];
cfg?: OpenClawConfig;
runtime?: RuntimeEnv;
accountId?: string;
telegramCfg?: TelegramAccountConfig;
allowFrom?: string[];
groupAllowFrom?: string[];
replyToMode?: RegisterTelegramNativeCommandParams["replyToMode"];
textLimit?: number;
useAccessGroups?: boolean;
nativeEnabled?: boolean;
nativeSkillsEnabled?: boolean;
nativeDisabledExplicit?: boolean;
resolveTelegramGroupConfig?: RegisterTelegramNativeCommandParams["resolveTelegramGroupConfig"];
opts?: RegisterTelegramNativeCommandParams["opts"];
}): RegisterTelegramNativeCommandParams {
return {
bot: params.bot,
cfg: params.cfg ?? {},
runtime: params.runtime ?? ({} as RuntimeEnv),
accountId: params.accountId ?? "default",
telegramCfg: params.telegramCfg ?? ({} as TelegramAccountConfig),
allowFrom: params.allowFrom ?? [],
groupAllowFrom: params.groupAllowFrom ?? [],
replyToMode: params.replyToMode ?? "off",
textLimit: params.textLimit ?? 4096,
useAccessGroups: params.useAccessGroups ?? false,
nativeEnabled: params.nativeEnabled ?? true,
nativeSkillsEnabled: params.nativeSkillsEnabled ?? true,
nativeDisabledExplicit: params.nativeDisabledExplicit ?? false,
resolveGroupPolicy: () => ({ allowlistEnabled: false, allowed: true }),
resolveTelegramGroupConfig:
params.resolveTelegramGroupConfig ??
(() => ({
groupConfig: undefined,
topicConfig: undefined,
})),
shouldSkipUpdate: () => false,
opts: params.opts ?? { token: "token" },
};
}