refactor: rename to openclaw

This commit is contained in:
Peter Steinberger
2026-01-30 03:15:10 +01:00
parent 4583f88626
commit 9a7160786a
2357 changed files with 16688 additions and 16788 deletions

View File

@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { resolveTelegramAccount } from "./accounts.js";
describe("resolveTelegramAccount", () => {
@@ -8,7 +8,7 @@ describe("resolveTelegramAccount", () => {
const prevTelegramToken = process.env.TELEGRAM_BOT_TOKEN;
process.env.TELEGRAM_BOT_TOKEN = "";
try {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: {
telegram: { accounts: { work: { botToken: "tok-work" } } },
},
@@ -31,7 +31,7 @@ describe("resolveTelegramAccount", () => {
const prevTelegramToken = process.env.TELEGRAM_BOT_TOKEN;
process.env.TELEGRAM_BOT_TOKEN = "tok-env";
try {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: {
telegram: { accounts: { work: { botToken: "tok-work" } } },
},
@@ -54,7 +54,7 @@ describe("resolveTelegramAccount", () => {
const prevTelegramToken = process.env.TELEGRAM_BOT_TOKEN;
process.env.TELEGRAM_BOT_TOKEN = "tok-env";
try {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: {
telegram: { botToken: "tok-config" },
},
@@ -77,7 +77,7 @@ describe("resolveTelegramAccount", () => {
const prevTelegramToken = process.env.TELEGRAM_BOT_TOKEN;
process.env.TELEGRAM_BOT_TOKEN = "";
try {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: {
telegram: { accounts: { work: { botToken: "tok-work" } } },
},

View File

@@ -1,4 +1,4 @@
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import type { TelegramAccountConfig } from "../config/types.js";
import { isTruthyEnvValue } from "../infra/env.js";
import { listBoundAccountIds, resolveDefaultAgentBoundAccountId } from "../routing/bindings.js";
@@ -6,7 +6,7 @@ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.j
import { resolveTelegramToken } from "./token.js";
const debugAccounts = (...args: unknown[]) => {
if (isTruthyEnvValue(process.env.CLAWDBOT_DEBUG_TELEGRAM_ACCOUNTS)) {
if (isTruthyEnvValue(process.env.OPENCLAW_DEBUG_TELEGRAM_ACCOUNTS)) {
console.warn("[telegram:accounts]", ...args);
}
};
@@ -20,7 +20,7 @@ export type ResolvedTelegramAccount = {
config: TelegramAccountConfig;
};
function listConfiguredAccountIds(cfg: MoltbotConfig): string[] {
function listConfiguredAccountIds(cfg: OpenClawConfig): string[] {
const accounts = cfg.channels?.telegram?.accounts;
if (!accounts || typeof accounts !== "object") return [];
const ids = new Set<string>();
@@ -31,7 +31,7 @@ function listConfiguredAccountIds(cfg: MoltbotConfig): string[] {
return [...ids];
}
export function listTelegramAccountIds(cfg: MoltbotConfig): string[] {
export function listTelegramAccountIds(cfg: OpenClawConfig): string[] {
const ids = Array.from(
new Set([...listConfiguredAccountIds(cfg), ...listBoundAccountIds(cfg, "telegram")]),
);
@@ -40,7 +40,7 @@ export function listTelegramAccountIds(cfg: MoltbotConfig): string[] {
return ids.sort((a, b) => a.localeCompare(b));
}
export function resolveDefaultTelegramAccountId(cfg: MoltbotConfig): string {
export function resolveDefaultTelegramAccountId(cfg: OpenClawConfig): string {
const boundDefault = resolveDefaultAgentBoundAccountId(cfg, "telegram");
if (boundDefault) return boundDefault;
const ids = listTelegramAccountIds(cfg);
@@ -49,7 +49,7 @@ export function resolveDefaultTelegramAccountId(cfg: MoltbotConfig): string {
}
function resolveAccountConfig(
cfg: MoltbotConfig,
cfg: OpenClawConfig,
accountId: string,
): TelegramAccountConfig | undefined {
const accounts = cfg.channels?.telegram?.accounts;
@@ -61,7 +61,7 @@ function resolveAccountConfig(
return matchKey ? (accounts[matchKey] as TelegramAccountConfig | undefined) : undefined;
}
function mergeTelegramAccountConfig(cfg: MoltbotConfig, accountId: string): TelegramAccountConfig {
function mergeTelegramAccountConfig(cfg: OpenClawConfig, accountId: string): TelegramAccountConfig {
const { accounts: _ignored, ...base } = (cfg.channels?.telegram ??
{}) as TelegramAccountConfig & { accounts?: unknown };
const account = resolveAccountConfig(cfg, accountId) ?? {};
@@ -69,7 +69,7 @@ function mergeTelegramAccountConfig(cfg: MoltbotConfig, accountId: string): Tele
}
export function resolveTelegramAccount(params: {
cfg: MoltbotConfig;
cfg: OpenClawConfig;
accountId?: string | null;
}): ResolvedTelegramAccount {
const hasExplicitAccountId = Boolean(params.accountId?.trim());
@@ -110,7 +110,7 @@ export function resolveTelegramAccount(params: {
return fallback;
}
export function listEnabledTelegramAccounts(cfg: MoltbotConfig): ResolvedTelegramAccount[] {
export function listEnabledTelegramAccounts(cfg: OpenClawConfig): ResolvedTelegramAccount[] {
return listTelegramAccountIds(cfg)
.map((accountId) => resolveTelegramAccount({ cfg, accountId }))
.filter((account) => account.enabled);

View File

@@ -4,7 +4,7 @@ import { buildTelegramMessageContext } from "./bot-message-context.js";
describe("buildTelegramMessageContext dm thread sessions", () => {
const baseConfig = {
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/clawd" } },
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/openclaw" } },
channels: { telegram: {} },
messages: { groupChat: { mentionPatterns: [] } },
} as never;
@@ -73,7 +73,7 @@ describe("buildTelegramMessageContext dm thread sessions", () => {
describe("buildTelegramMessageContext group sessions without forum", () => {
const baseConfig = {
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/clawd" } },
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/openclaw" } },
channels: { telegram: {} },
messages: { groupChat: { mentionPatterns: [] } },
} as never;

View File

@@ -25,7 +25,7 @@ describe("buildTelegramMessageContext sender prefix", () => {
},
} as never,
cfg: {
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/clawd" } },
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/openclaw" } },
channels: { telegram: {} },
messages: { groupChat: { mentionPatterns: [] } },
} as never,
@@ -72,7 +72,7 @@ describe("buildTelegramMessageContext sender prefix", () => {
},
} as never,
cfg: {
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/clawd" } },
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/openclaw" } },
channels: { telegram: {} },
messages: { groupChat: { mentionPatterns: [] } },
} as never,
@@ -118,7 +118,7 @@ describe("buildTelegramMessageContext sender prefix", () => {
},
} as never,
cfg: {
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/clawd" } },
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/openclaw" } },
channels: { telegram: {} },
messages: { groupChat: { mentionPatterns: [] } },
} as never,

View File

@@ -21,7 +21,7 @@ import { formatLocationText, toLocationContext } from "../channels/location.js";
import { recordInboundSession } from "../channels/session.js";
import { formatCliCommand } from "../cli/command-format.js";
import { readSessionUpdatedAt, resolveStorePath } from "../config/sessions.js";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import type { DmPolicy, TelegramGroupConfig, TelegramTopicConfig } from "../config/types.js";
import { logVerbose, shouldLogVerbose } from "../globals.js";
import { recordChannelActivity } from "../infra/channel-activity.js";
@@ -96,7 +96,7 @@ type BuildTelegramMessageContextParams = {
storeAllowFrom: string[];
options?: TelegramMessageContextOptions;
bot: Bot;
cfg: MoltbotConfig;
cfg: OpenClawConfig;
account: { accountId: string };
historyLimit: number;
groupHistories: Map<string, HistoryEntry[]>;
@@ -111,7 +111,7 @@ type BuildTelegramMessageContextParams = {
};
async function resolveStickerVisionSupport(params: {
cfg: MoltbotConfig;
cfg: OpenClawConfig;
agentId?: string;
}): Promise<boolean> {
try {
@@ -272,14 +272,14 @@ export const buildTelegramMessageContext = async ({
bot.api.sendMessage(
chatId,
[
"Moltbot: access not configured.",
"OpenClaw: access not configured.",
"",
`Your Telegram user id: ${telegramUserId}`,
"",
`Pairing code: ${code}`,
"",
"Ask the bot owner to approve with:",
formatCliCommand("moltbot pairing approve telegram <code>"),
formatCliCommand("openclaw pairing approve telegram <code>"),
].join("\n"),
),
});

View File

@@ -1,7 +1,7 @@
import { describe, expect, it, vi } from "vitest";
import type { ChannelGroupPolicy } from "../config/group-policy.js";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import type { TelegramAccountConfig } from "../config/types.js";
import type { RuntimeEnv } from "../runtime.js";
import { registerTelegramNativeCommands } from "./bot-native-commands.js";
@@ -47,7 +47,7 @@ describe("registerTelegramNativeCommands (plugin auth)", () => {
},
} as const;
const cfg = {} as MoltbotConfig;
const cfg = {} as OpenClawConfig;
const telegramCfg = {} as TelegramAccountConfig;
const resolveGroupPolicy = () =>
({

View File

@@ -37,7 +37,7 @@ import type {
TelegramGroupConfig,
TelegramTopicConfig,
} from "../config/types.js";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import type { RuntimeEnv } from "../runtime.js";
import { deliverReplies } from "./bot/delivery.js";
import { buildInlineKeyboard } from "./send.js";
@@ -68,7 +68,7 @@ type TelegramCommandAuthResult = {
type RegisterTelegramNativeCommandsParams = {
bot: Bot;
cfg: MoltbotConfig;
cfg: OpenClawConfig;
runtime: RuntimeEnv;
accountId: string;
telegramCfg: TelegramAccountConfig;
@@ -92,7 +92,7 @@ type RegisterTelegramNativeCommandsParams = {
async function resolveTelegramCommandAuth(params: {
msg: NonNullable<TelegramNativeCommandContext["message"]>;
bot: Bot;
cfg: MoltbotConfig;
cfg: OpenClawConfig;
telegramCfg: TelegramAccountConfig;
allowFrom?: Array<string | number>;
groupAllowFrom?: Array<string | number>;

View File

@@ -5,7 +5,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/openclaw-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -196,7 +196,7 @@ describe("createTelegramBot", () => {
message_id: 1,
from: { id: 9, first_name: "Ada" },
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -245,7 +245,7 @@ describe("createTelegramBot", () => {
message_id: 3,
from: { id: 9, first_name: "Ada" },
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -288,7 +288,7 @@ describe("createTelegramBot", () => {
username: "ada",
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -334,7 +334,7 @@ describe("createTelegramBot", () => {
message_id: 123,
from: { id: 9, first_name: "Ada" },
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -375,7 +375,7 @@ describe("createTelegramBot", () => {
message_id: 2,
from: { id: 9, first_name: "Ada" },
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -435,7 +435,7 @@ describe("createTelegramBot", () => {
from: { first_name: "Ada" },
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -4,7 +4,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/openclaw-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -201,7 +201,7 @@ describe("createTelegramBot", () => {
message_id: 42,
message_thread_id: 99,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -245,7 +245,7 @@ describe("createTelegramBot", () => {
message_id: 42,
message_thread_id: 99,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -365,7 +365,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
};

View File

@@ -4,7 +4,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/openclaw-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -178,10 +178,10 @@ describe("createTelegramBot", () => {
message: {
chat: { id: -100123456789, type: "group", title: "Test Group" },
from: { id: 123456789, username: "testuser" },
text: "@moltbot_bot hello",
text: "@openclaw_bot hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -208,10 +208,10 @@ describe("createTelegramBot", () => {
message: {
chat: { id: -100123456789, type: "group", title: "Test Group" },
from: { id: 999999, username: "notallowed" }, // Not in allowFrom
text: "@moltbot_bot hello",
text: "@openclaw_bot hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -241,7 +241,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -271,7 +271,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -301,7 +301,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -331,7 +331,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -360,7 +360,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -4,7 +4,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/openclaw-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -186,7 +186,7 @@ describe("createTelegramBot", () => {
message_id: 9001,
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({}),
};
@@ -222,7 +222,7 @@ describe("createTelegramBot", () => {
message_id: 9001,
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({}),
});
@@ -237,7 +237,7 @@ describe("createTelegramBot", () => {
message_id: 9001,
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({}),
});

View File

@@ -7,7 +7,7 @@ let getTelegramSequentialKey: typeof import("./bot.js").getTelegramSequentialKey
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/moltbot-telegram-throttler-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/openclaw-telegram-throttler-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
loadWebMedia: vi.fn(),
@@ -294,7 +294,7 @@ describe("createTelegramBot", () => {
message_id: 10,
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -328,7 +328,7 @@ describe("createTelegramBot", () => {
};
await handler({
message,
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -371,7 +371,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
from: { id: 999, username: "random" },
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -408,12 +408,12 @@ describe("createTelegramBot", () => {
await handler({
message,
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
await handler({
message: { ...message, text: "hello again" },
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -428,7 +428,7 @@ describe("createTelegramBot", () => {
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
await handler({
message: { chat: { id: 42, type: "private" }, text: "hi" },
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -4,7 +4,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/openclaw-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -182,7 +182,7 @@ describe("createTelegramBot", () => {
text: "hello from prefixed user",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -212,7 +212,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -242,7 +242,7 @@ describe("createTelegramBot", () => {
text: "/status",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -280,7 +280,7 @@ describe("createTelegramBot", () => {
message_id: 42,
message_thread_id: 99,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -325,7 +325,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -366,7 +366,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -4,7 +4,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/openclaw-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -182,7 +182,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -211,7 +211,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -239,7 +239,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -267,7 +267,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -297,7 +297,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -326,7 +326,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -356,7 +356,7 @@ describe("createTelegramBot", () => {
text: "hello from prefixed user",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -4,7 +4,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/moltbot-telegram-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/openclaw-telegram-${Math.random().toString(16).slice(2)}.json`,
}));
const { loadWebMedia } = vi.hoisted(() => ({
@@ -193,7 +193,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -227,7 +227,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -269,7 +269,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_thread_id: 99,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -297,7 +297,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -357,7 +357,7 @@ describe("createTelegramBot", () => {
message_id: 5,
from: { first_name: "Ada" },
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -7,7 +7,7 @@ let createTelegramBot: typeof import("./bot.js").createTelegramBot;
let resetInboundDedupe: typeof import("../auto-reply/reply/inbound-dedupe.js").resetInboundDedupe;
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/moltbot-telegram-reply-threading-${Math.random()
sessionStorePath: `/tmp/openclaw-telegram-reply-threading-${Math.random()
.toString(16)
.slice(2)}.json`,
}));
@@ -179,7 +179,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 101,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -207,7 +207,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 101,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -239,7 +239,7 @@ describe("createTelegramBot", () => {
text: "hi",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -265,7 +265,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 101,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -294,10 +294,10 @@ describe("createTelegramBot", () => {
await handler({
message: {
chat: { id: 456, type: "group", title: "Ops" },
text: "@moltbot_bot hello",
text: "@openclaw_bot hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -322,7 +322,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -332,7 +332,7 @@ describe("createTelegramBot", () => {
onSpy.mockReset();
const replySpy = replyModule.__replySpy as unknown as ReturnType<typeof vi.fn>;
replySpy.mockReset();
const storeDir = fs.mkdtempSync(path.join(os.tmpdir(), "moltbot-telegram-"));
const storeDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-telegram-"));
const storePath = path.join(storeDir, "sessions.json");
fs.writeFileSync(
storePath,
@@ -369,7 +369,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});

View File

@@ -151,7 +151,7 @@ describe("telegram inbound media", () => {
photo: [{ file_id: "fid" }],
date: 1736380800, // 2025-01-09T00:00:00Z
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ file_path: "photos/1.jpg" }),
});
@@ -206,7 +206,7 @@ describe("telegram inbound media", () => {
chat: { id: 1234, type: "private" },
photo: [{ file_id: "fid" }],
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ file_path: "photos/2.jpg" }),
});
@@ -249,7 +249,7 @@ describe("telegram inbound media", () => {
chat: { id: 1234, type: "private" },
photo: [{ file_id: "fid" }],
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({}),
});
@@ -319,7 +319,7 @@ describe("telegram media groups", () => {
media_group_id: "album123",
photo: [{ file_id: "photo1" }],
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ file_path: "photos/photo1.jpg" }),
});
@@ -331,7 +331,7 @@ describe("telegram media groups", () => {
media_group_id: "album123",
photo: [{ file_id: "photo2" }],
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ file_path: "photos/photo2.jpg" }),
});
@@ -385,7 +385,7 @@ describe("telegram media groups", () => {
media_group_id: "albumA",
photo: [{ file_id: "photoA1" }],
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ file_path: "photos/photoA1.jpg" }),
});
@@ -398,7 +398,7 @@ describe("telegram media groups", () => {
media_group_id: "albumB",
photo: [{ file_id: "photoB1" }],
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ file_path: "photos/photoB1.jpg" }),
});
@@ -477,7 +477,7 @@ describe("telegram stickers", () => {
},
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ file_path: "stickers/sticker.webp" }),
});
@@ -558,7 +558,7 @@ describe("telegram stickers", () => {
},
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ file_path: "stickers/sticker.webp" }),
});
@@ -624,7 +624,7 @@ describe("telegram stickers", () => {
},
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ file_path: "stickers/animated.tgs" }),
});
@@ -684,7 +684,7 @@ describe("telegram stickers", () => {
},
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ file_path: "stickers/video.webm" }),
});
@@ -737,7 +737,7 @@ describe("telegram text fragments", () => {
date: 1736380800,
text: part1,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({}),
});
@@ -748,7 +748,7 @@ describe("telegram text fragments", () => {
date: 1736380801,
text: part2,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({}),
});

View File

@@ -123,7 +123,7 @@ describe("telegram inbound media", () => {
horizontal_accuracy: 12,
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ file_path: "unused" }),
});
@@ -166,7 +166,7 @@ describe("telegram inbound media", () => {
location: { latitude: 48.858844, longitude: 2.294351 },
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ file_path: "unused" }),
});

View File

@@ -22,7 +22,7 @@ vi.mock("../auto-reply/skill-commands.js", () => ({
}));
const { sessionStorePath } = vi.hoisted(() => ({
sessionStorePath: `/tmp/moltbot-telegram-bot-${Math.random().toString(16).slice(2)}.json`,
sessionStorePath: `/tmp/openclaw-telegram-bot-${Math.random().toString(16).slice(2)}.json`,
}));
function resolveSkillCommands(config: Parameters<typeof listNativeCommandSpecsForConfig>[0]) {
@@ -382,7 +382,7 @@ describe("createTelegramBot", () => {
message_id: 10,
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -425,7 +425,7 @@ describe("createTelegramBot", () => {
message_id: 11,
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -454,7 +454,7 @@ describe("createTelegramBot", () => {
message_id: 12,
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -506,7 +506,7 @@ describe("createTelegramBot", () => {
message_id: 13,
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -539,7 +539,7 @@ describe("createTelegramBot", () => {
};
await handler({
message,
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -583,7 +583,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
from: { id: 999, username: "random" },
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -621,12 +621,12 @@ describe("createTelegramBot", () => {
await handler({
message,
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
await handler({
message: { ...message, text: "hello again" },
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -642,7 +642,7 @@ describe("createTelegramBot", () => {
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
await handler({
message: { chat: { id: 42, type: "private" }, text: "hi" },
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -681,7 +681,7 @@ describe("createTelegramBot", () => {
message_id: 1,
from: { id: 9, first_name: "Ada" },
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -733,7 +733,7 @@ describe("createTelegramBot", () => {
username: "ada",
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -781,7 +781,7 @@ describe("createTelegramBot", () => {
message_id: 123,
from: { id: 9, first_name: "Ada" },
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -824,7 +824,7 @@ describe("createTelegramBot", () => {
message_id: 2,
from: { id: 9, first_name: "Ada" },
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -886,7 +886,7 @@ describe("createTelegramBot", () => {
from: { first_name: "Ada" },
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -922,7 +922,7 @@ describe("createTelegramBot", () => {
text: "summarize this",
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -953,7 +953,7 @@ describe("createTelegramBot", () => {
text: "summarize this",
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -982,7 +982,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 101,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1011,7 +1011,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 101,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1044,7 +1044,7 @@ describe("createTelegramBot", () => {
text: "hi",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1071,7 +1071,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 101,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1101,10 +1101,10 @@ describe("createTelegramBot", () => {
await handler({
message: {
chat: { id: 456, type: "group", title: "Ops" },
text: "@moltbot_bot hello",
text: "@openclaw_bot hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1130,7 +1130,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1158,10 +1158,10 @@ describe("createTelegramBot", () => {
reply_to_message: {
message_id: 42,
text: "original reply",
from: { id: 999, first_name: "Moltbot" },
from: { id: 999, first_name: "OpenClaw" },
},
},
me: { id: 999, username: "moltbot_bot" },
me: { id: 999, username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1174,7 +1174,7 @@ describe("createTelegramBot", () => {
onSpy.mockReset();
const replySpy = replyModule.__replySpy as unknown as ReturnType<typeof vi.fn>;
replySpy.mockReset();
const storeDir = fs.mkdtempSync(path.join(os.tmpdir(), "moltbot-telegram-"));
const storeDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-telegram-"));
const storePath = path.join(storeDir, "sessions.json");
fs.writeFileSync(
storePath,
@@ -1211,7 +1211,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1253,7 +1253,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1288,7 +1288,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1331,7 +1331,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_thread_id: 99,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1375,7 +1375,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_thread_id: 99,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1418,7 +1418,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_thread_id: 99,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1447,7 +1447,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1509,7 +1509,7 @@ describe("createTelegramBot", () => {
message_id: 5,
from: { first_name: "Ada" },
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1543,10 +1543,10 @@ describe("createTelegramBot", () => {
message: {
chat: { id: -100123456789, type: "group", title: "Test Group" },
from: { id: 123456789, username: "testuser" },
text: "@moltbot_bot hello",
text: "@openclaw_bot hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1574,10 +1574,10 @@ describe("createTelegramBot", () => {
message: {
chat: { id: -100123456789, type: "group", title: "Test Group" },
from: { id: 999999, username: "notallowed" }, // Not in allowFrom
text: "@moltbot_bot hello",
text: "@openclaw_bot hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1608,7 +1608,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1639,7 +1639,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1670,7 +1670,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1701,7 +1701,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1731,7 +1731,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1762,7 +1762,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1792,7 +1792,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1821,7 +1821,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1850,7 +1850,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1881,7 +1881,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1911,7 +1911,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1942,7 +1942,7 @@ describe("createTelegramBot", () => {
text: "hello from prefixed user",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -1974,7 +1974,7 @@ describe("createTelegramBot", () => {
text: "hello from prefixed user",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2005,7 +2005,7 @@ describe("createTelegramBot", () => {
text: "hello",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2036,7 +2036,7 @@ describe("createTelegramBot", () => {
text: "/status",
date: 1736380800,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2075,7 +2075,7 @@ describe("createTelegramBot", () => {
message_id: 42,
message_thread_id: 99,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2121,7 +2121,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2163,7 +2163,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2215,7 +2215,7 @@ describe("createTelegramBot", () => {
message_id: 42,
message_thread_id: 99,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2260,7 +2260,7 @@ describe("createTelegramBot", () => {
message_id: 42,
message_thread_id: 99,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
@@ -2507,7 +2507,7 @@ describe("createTelegramBot", () => {
date: 1736380800,
message_id: 42,
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
};
@@ -2545,7 +2545,7 @@ describe("createTelegramBot", () => {
message_id: 9001,
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({}),
};
@@ -2582,7 +2582,7 @@ describe("createTelegramBot", () => {
message_id: 9001,
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({}),
});
@@ -2597,7 +2597,7 @@ describe("createTelegramBot", () => {
message_id: 9001,
},
},
me: { username: "moltbot_bot" },
me: { username: "openclaw_bot" },
getFile: async () => ({}),
});

View File

@@ -12,7 +12,7 @@ import {
resolveNativeCommandsEnabled,
resolveNativeSkillsEnabled,
} from "../config/commands.js";
import type { MoltbotConfig, ReplyToMode } from "../config/config.js";
import type { OpenClawConfig, ReplyToMode } from "../config/config.js";
import { loadConfig } from "../config/config.js";
import {
resolveChannelGroupPolicy,
@@ -57,7 +57,7 @@ export type TelegramBotOptions = {
mediaMaxMb?: number;
replyToMode?: ReplyToMode;
proxyFetch?: typeof fetch;
config?: MoltbotConfig;
config?: OpenClawConfig;
updateOffset?: {
lastUpdateId?: number | null;
onUpdateId?: (updateId: number) => void | Promise<void>;

View File

@@ -91,8 +91,8 @@ describe("normalizeForwardedContext", () => {
it("handles legacy forwards with signatures", () => {
const ctx = normalizeForwardedContext({
forward_from_chat: {
title: "Moltbot Updates",
username: "moltbot",
title: "OpenClaw Updates",
username: "openclaw",
id: 99,
type: "channel",
},
@@ -100,11 +100,11 @@ describe("normalizeForwardedContext", () => {
forward_date: 789,
} as any);
expect(ctx).not.toBeNull();
expect(ctx?.from).toBe("Moltbot Updates (Stan)");
expect(ctx?.from).toBe("OpenClaw Updates (Stan)");
expect(ctx?.fromType).toBe("legacy_channel");
expect(ctx?.fromId).toBe("99");
expect(ctx?.fromUsername).toBe("moltbot");
expect(ctx?.fromTitle).toBe("Moltbot Updates");
expect(ctx?.fromUsername).toBe("openclaw");
expect(ctx?.fromTitle).toBe("OpenClaw Updates");
expect(ctx?.fromSignature).toBe("Stan");
expect(ctx?.date).toBe(789);
});

View File

@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import type { MoltbotConfig } from "../../config/config.js";
import type { OpenClawConfig } from "../../config/config.js";
import { resolveTelegramDraftStreamingChunking } from "./draft-chunking.js";
describe("resolveTelegramDraftStreamingChunking", () => {
@@ -14,7 +14,7 @@ describe("resolveTelegramDraftStreamingChunking", () => {
});
it("clamps to telegram.textChunkLimit", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: { telegram: { allowFrom: ["*"], textChunkLimit: 150 } },
};
const chunking = resolveTelegramDraftStreamingChunking(cfg, "default");
@@ -26,7 +26,7 @@ describe("resolveTelegramDraftStreamingChunking", () => {
});
it("supports per-account overrides", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: {
telegram: {
allowFrom: ["*"],

View File

@@ -1,13 +1,13 @@
import { resolveTextChunkLimit } from "../auto-reply/chunk.js";
import { getChannelDock } from "../channels/dock.js";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { normalizeAccountId } from "../routing/session-key.js";
const DEFAULT_TELEGRAM_DRAFT_STREAM_MIN = 200;
const DEFAULT_TELEGRAM_DRAFT_STREAM_MAX = 800;
export function resolveTelegramDraftStreamingChunking(
cfg: MoltbotConfig | undefined,
cfg: OpenClawConfig | undefined,
accountId?: string | null,
): {
minChars: number;

View File

@@ -39,7 +39,7 @@ describe("resolveTelegramFetch", () => {
});
it("honors env enable override", async () => {
vi.stubEnv("CLAWDBOT_TELEGRAM_ENABLE_AUTO_SELECT_FAMILY", "1");
vi.stubEnv("OPENCLAW_TELEGRAM_ENABLE_AUTO_SELECT_FAMILY", "1");
globalThis.fetch = vi.fn(async () => ({})) as unknown as typeof fetch;
const { resolveTelegramFetch, setDefaultAutoSelectFamily } = await loadModule();
resolveTelegramFetch();
@@ -54,7 +54,7 @@ describe("resolveTelegramFetch", () => {
});
it("env disable override wins over config", async () => {
vi.stubEnv("CLAWDBOT_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY", "1");
vi.stubEnv("OPENCLAW_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY", "1");
globalThis.fetch = vi.fn(async () => ({})) as unknown as typeof fetch;
const { resolveTelegramFetch, setDefaultAutoSelectFamily } = await loadModule();
resolveTelegramFetch(undefined, { network: { autoSelectFamily: true } });

View File

@@ -1,4 +1,4 @@
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import type { TelegramGroupConfig } from "../config/types.telegram.js";
import { normalizeAccountId } from "../routing/session-key.js";
@@ -13,7 +13,7 @@ export type TelegramGroupMigrationResult = {
};
function resolveAccountGroups(
cfg: MoltbotConfig,
cfg: OpenClawConfig,
accountId?: string | null,
): { groups?: TelegramGroups } {
if (!accountId) return {};
@@ -43,7 +43,7 @@ export function migrateTelegramGroupsInPlace(
}
export function migrateTelegramGroupConfig(params: {
cfg: MoltbotConfig;
cfg: OpenClawConfig;
accountId?: string | null;
oldChatId: string;
newChatId: string;

View File

@@ -1,4 +1,4 @@
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import type { TelegramInlineButtonsScope } from "../config/types.telegram.js";
import { listTelegramAccountIds, resolveTelegramAccount } from "./accounts.js";
import { parseTelegramTarget } from "./targets.js";
@@ -38,7 +38,7 @@ function resolveInlineButtonsScopeFromCapabilities(
}
export function resolveTelegramInlineButtonsScope(params: {
cfg: MoltbotConfig;
cfg: OpenClawConfig;
accountId?: string | null;
}): TelegramInlineButtonsScope {
const account = resolveTelegramAccount({ cfg: params.cfg, accountId: params.accountId });
@@ -46,7 +46,7 @@ export function resolveTelegramInlineButtonsScope(params: {
}
export function isTelegramInlineButtonsEnabled(params: {
cfg: MoltbotConfig;
cfg: OpenClawConfig;
accountId?: string | null;
}): boolean {
if (params.accountId) {

View File

@@ -1,5 +1,5 @@
import { type RunOptions, run } from "@grammyjs/runner";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { loadConfig } from "../config/config.js";
import { resolveAgentMaxConcurrent } from "../config/agent-limits.js";
import { computeBackoff, sleepWithAbort } from "../infra/backoff.js";
@@ -17,7 +17,7 @@ import { startTelegramWebhook } from "./webhook.js";
export type MonitorTelegramOpts = {
token?: string;
accountId?: string;
config?: MoltbotConfig;
config?: OpenClawConfig;
runtime?: RuntimeEnv;
abortSignal?: AbortSignal;
useWebhook?: boolean;
@@ -28,7 +28,7 @@ export type MonitorTelegramOpts = {
webhookUrl?: string;
};
export function createTelegramRunnerOptions(cfg: MoltbotConfig): RunOptions<unknown> {
export function createTelegramRunnerOptions(cfg: OpenClawConfig): RunOptions<unknown> {
return {
sink: {
concurrency: resolveAgentMaxConcurrent(cfg),

View File

@@ -6,25 +6,25 @@ describe("resolveTelegramAutoSelectFamilyDecision", () => {
it("prefers env enable over env disable", () => {
const decision = resolveTelegramAutoSelectFamilyDecision({
env: {
CLAWDBOT_TELEGRAM_ENABLE_AUTO_SELECT_FAMILY: "1",
CLAWDBOT_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY: "1",
OPENCLAW_TELEGRAM_ENABLE_AUTO_SELECT_FAMILY: "1",
OPENCLAW_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY: "1",
},
nodeMajor: 22,
});
expect(decision).toEqual({
value: true,
source: "env:CLAWDBOT_TELEGRAM_ENABLE_AUTO_SELECT_FAMILY",
source: "env:OPENCLAW_TELEGRAM_ENABLE_AUTO_SELECT_FAMILY",
});
});
it("uses env disable when set", () => {
const decision = resolveTelegramAutoSelectFamilyDecision({
env: { CLAWDBOT_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY: "1" },
env: { OPENCLAW_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY: "1" },
nodeMajor: 22,
});
expect(decision).toEqual({
value: false,
source: "env:CLAWDBOT_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY",
source: "env:OPENCLAW_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY",
});
});

View File

@@ -4,8 +4,8 @@ import { isTruthyEnvValue } from "../infra/env.js";
import type { TelegramNetworkConfig } from "../config/types.telegram.js";
export const TELEGRAM_DISABLE_AUTO_SELECT_FAMILY_ENV =
"CLAWDBOT_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY";
export const TELEGRAM_ENABLE_AUTO_SELECT_FAMILY_ENV = "CLAWDBOT_TELEGRAM_ENABLE_AUTO_SELECT_FAMILY";
"OPENCLAW_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY";
export const TELEGRAM_ENABLE_AUTO_SELECT_FAMILY_ENV = "OPENCLAW_TELEGRAM_ENABLE_AUTO_SELECT_FAMILY";
export type TelegramAutoSelectFamilyDecision = {
value: boolean | null;

View File

@@ -12,14 +12,14 @@ import {
} from "./pairing-store.js";
async function withTempStateDir<T>(fn: (stateDir: string) => Promise<T>) {
const previous = process.env.CLAWDBOT_STATE_DIR;
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-pairing-"));
process.env.CLAWDBOT_STATE_DIR = dir;
const previous = process.env.OPENCLAW_STATE_DIR;
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-pairing-"));
process.env.OPENCLAW_STATE_DIR = dir;
try {
return await fn(dir);
} finally {
if (previous === undefined) delete process.env.CLAWDBOT_STATE_DIR;
else process.env.CLAWDBOT_STATE_DIR = previous;
if (previous === undefined) delete process.env.OPENCLAW_STATE_DIR;
else process.env.OPENCLAW_STATE_DIR = previous;
await fs.rm(dir, { recursive: true, force: true });
}
}

View File

@@ -1,4 +1,4 @@
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import {
addChannelAllowFromStoreEntry,
approveChannelPairingCode,
@@ -95,7 +95,7 @@ export async function approveTelegramPairingCode(params: {
}
export async function resolveTelegramEffectiveAllowFrom(params: {
cfg: MoltbotConfig;
cfg: OpenClawConfig;
env?: NodeJS.ProcessEnv;
}): Promise<{ dm: string[]; group: string[] }> {
const env = params.env ?? process.env;

View File

@@ -1,6 +1,6 @@
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { resolveTelegramReactionLevel } from "./reaction-level.js";
describe("resolveTelegramReactionLevel", () => {
@@ -19,7 +19,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("defaults to minimal level when reactionLevel is not set", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: { telegram: {} },
};
@@ -31,7 +31,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("returns off level with no reactions enabled", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: { telegram: { reactionLevel: "off" } },
};
@@ -43,7 +43,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("returns ack level with only ackEnabled", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: { telegram: { reactionLevel: "ack" } },
};
@@ -55,7 +55,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("returns minimal level with agent reactions enabled and minimal guidance", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: { telegram: { reactionLevel: "minimal" } },
};
@@ -67,7 +67,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("returns extensive level with agent reactions enabled and extensive guidance", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: { telegram: { reactionLevel: "extensive" } },
};
@@ -79,7 +79,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("resolves reaction level from a specific account", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: {
telegram: {
reactionLevel: "ack",
@@ -98,7 +98,7 @@ describe("resolveTelegramReactionLevel", () => {
});
it("falls back to global level when account has no reactionLevel", () => {
const cfg: MoltbotConfig = {
const cfg: OpenClawConfig = {
channels: {
telegram: {
reactionLevel: "minimal",

View File

@@ -1,4 +1,4 @@
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { resolveTelegramAccount } from "./accounts.js";
export type TelegramReactionLevel = "off" | "ack" | "minimal" | "extensive";
@@ -17,7 +17,7 @@ export type ResolvedReactionLevel = {
* Resolve the effective reaction level and its implications.
*/
export function resolveTelegramReactionLevel(params: {
cfg: MoltbotConfig;
cfg: OpenClawConfig;
accountId?: string;
}): ResolvedReactionLevel {
const account = resolveTelegramAccount({

View File

@@ -11,10 +11,10 @@ import {
// Mock the state directory to use a temp location
vi.mock("../config/paths.js", () => ({
STATE_DIR: "/tmp/moltbot-test-sticker-cache",
STATE_DIR: "/tmp/openclaw-test-sticker-cache",
}));
const TEST_CACHE_DIR = "/tmp/moltbot-test-sticker-cache/telegram";
const TEST_CACHE_DIR = "/tmp/openclaw-test-sticker-cache/telegram";
const TEST_CACHE_FILE = path.join(TEST_CACHE_DIR, "sticker-cache.json");
describe("sticker-cache", () => {

View File

@@ -1,6 +1,6 @@
import fs from "node:fs/promises";
import path from "node:path";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { STATE_DIR } from "../config/paths.js";
import { loadJsonFile, saveJsonFile } from "../infra/json-file.js";
import { logVerbose } from "../globals.js";
@@ -146,7 +146,7 @@ const VISION_PROVIDERS = ["openai", "anthropic", "google", "minimax"] as const;
export interface DescribeStickerParams {
imagePath: string;
cfg: MoltbotConfig;
cfg: OpenClawConfig;
agentDir?: string;
agentId?: string;
}

View File

@@ -4,11 +4,11 @@ import path from "node:path";
import { afterEach, describe, expect, it, vi } from "vitest";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { resolveTelegramToken } from "./token.js";
function withTempDir(): string {
return fs.mkdtempSync(path.join(os.tmpdir(), "moltbot-telegram-token-"));
return fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-telegram-token-"));
}
describe("resolveTelegramToken", () => {
@@ -20,7 +20,7 @@ describe("resolveTelegramToken", () => {
vi.stubEnv("TELEGRAM_BOT_TOKEN", "env-token");
const cfg = {
channels: { telegram: { botToken: "cfg-token" } },
} as MoltbotConfig;
} as OpenClawConfig;
const res = resolveTelegramToken(cfg);
expect(res.token).toBe("cfg-token");
expect(res.source).toBe("config");
@@ -30,7 +30,7 @@ describe("resolveTelegramToken", () => {
vi.stubEnv("TELEGRAM_BOT_TOKEN", "env-token");
const cfg = {
channels: { telegram: {} },
} as MoltbotConfig;
} as OpenClawConfig;
const res = resolveTelegramToken(cfg);
expect(res.token).toBe("env-token");
expect(res.source).toBe("env");
@@ -41,7 +41,7 @@ describe("resolveTelegramToken", () => {
const dir = withTempDir();
const tokenFile = path.join(dir, "token.txt");
fs.writeFileSync(tokenFile, "file-token\n", "utf-8");
const cfg = { channels: { telegram: { tokenFile } } } as MoltbotConfig;
const cfg = { channels: { telegram: { tokenFile } } } as OpenClawConfig;
const res = resolveTelegramToken(cfg);
expect(res.token).toBe("file-token");
expect(res.source).toBe("tokenFile");
@@ -52,7 +52,7 @@ describe("resolveTelegramToken", () => {
vi.stubEnv("TELEGRAM_BOT_TOKEN", "");
const cfg = {
channels: { telegram: { botToken: "cfg-token" } },
} as MoltbotConfig;
} as OpenClawConfig;
const res = resolveTelegramToken(cfg);
expect(res.token).toBe("cfg-token");
expect(res.source).toBe("config");
@@ -64,7 +64,7 @@ describe("resolveTelegramToken", () => {
const tokenFile = path.join(dir, "missing-token.txt");
const cfg = {
channels: { telegram: { tokenFile, botToken: "cfg-token" } },
} as MoltbotConfig;
} as OpenClawConfig;
const res = resolveTelegramToken(cfg);
expect(res.token).toBe("");
expect(res.source).toBe("none");

View File

@@ -1,6 +1,6 @@
import fs from "node:fs";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";
export type TelegramTokenSource = "env" | "tokenFile" | "config" | "none";
@@ -17,7 +17,7 @@ type ResolveTelegramTokenOpts = {
};
export function resolveTelegramToken(
cfg?: MoltbotConfig,
cfg?: OpenClawConfig,
opts: ResolveTelegramTokenOpts = {},
): TelegramTokenResolution {
const accountId = normalizeAccountId(opts.accountId);

View File

@@ -7,14 +7,14 @@ import { describe, expect, it } from "vitest";
import { readTelegramUpdateOffset, writeTelegramUpdateOffset } from "./update-offset-store.js";
async function withTempStateDir<T>(fn: (dir: string) => Promise<T>) {
const previous = process.env.CLAWDBOT_STATE_DIR;
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-telegram-"));
process.env.CLAWDBOT_STATE_DIR = dir;
const previous = process.env.OPENCLAW_STATE_DIR;
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-telegram-"));
process.env.OPENCLAW_STATE_DIR = dir;
try {
return await fn(dir);
} finally {
if (previous === undefined) delete process.env.CLAWDBOT_STATE_DIR;
else process.env.CLAWDBOT_STATE_DIR = previous;
if (previous === undefined) delete process.env.OPENCLAW_STATE_DIR;
else process.env.OPENCLAW_STATE_DIR = previous;
await fs.rm(dir, { recursive: true, force: true });
}
}

View File

@@ -1,7 +1,7 @@
import { createServer } from "node:http";
import { webhookCallback } from "grammy";
import type { MoltbotConfig } from "../config/config.js";
import type { OpenClawConfig } from "../config/config.js";
import { isDiagnosticsEnabled } from "../infra/diagnostic-events.js";
import { formatErrorMessage } from "../infra/errors.js";
import type { RuntimeEnv } from "../runtime.js";
@@ -20,7 +20,7 @@ import { withTelegramApiErrorLogging } from "./api-logging.js";
export async function startTelegramWebhook(opts: {
token: string;
accountId?: string;
config?: MoltbotConfig;
config?: OpenClawConfig;
path?: string;
port?: number;
host?: string;