From f13db1c836f34acb27dbed2c0ae7d5df76a22c33 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 12 Jan 2026 22:12:16 +0000 Subject: [PATCH] test: guard telegram native commands when mock lacks .command --- src/telegram/bot.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/telegram/bot.ts b/src/telegram/bot.ts index 54e560224..f3eb3f0f4 100644 --- a/src/telegram/bot.ts +++ b/src/telegram/bot.ts @@ -951,13 +951,18 @@ export function createTelegramBot(opts: TelegramBotOptions) { ); } - for (const command of nativeCommands) { - bot.command(command.name, async (ctx) => { - const msg = ctx.message; - if (!msg) return; - if (shouldSkipUpdate(ctx)) return; - const chatId = msg.chat.id; - const isGroup = + if (typeof bot.command !== "function") { + runtime.info?.( + "telegram: bot.command not available on api mock; skipping native command handlers", + ); + } else { + for (const command of nativeCommands) { + bot.command(command.name, async (ctx) => { + const msg = ctx.message; + if (!msg) return; + if (shouldSkipUpdate(ctx)) return; + const chatId = msg.chat.id; + const isGroup = msg.chat.type === "group" || msg.chat.type === "supergroup"; const messageThreadId = (msg as { message_thread_id?: number }) .message_thread_id; @@ -1138,7 +1143,8 @@ export function createTelegramBot(opts: TelegramBotOptions) { textLimit, messageThreadId, }); - }); + }); + } } } else if (nativeDisabledExplicit) { bot.api.setMyCommands([]).catch((err) => {