test: guard telegram native commands when mock lacks .command
This commit is contained in:
@@ -951,6 +951,11 @@ export function createTelegramBot(opts: TelegramBotOptions) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
for (const command of nativeCommands) {
|
||||||
bot.command(command.name, async (ctx) => {
|
bot.command(command.name, async (ctx) => {
|
||||||
const msg = ctx.message;
|
const msg = ctx.message;
|
||||||
@@ -1140,6 +1145,7 @@ export function createTelegramBot(opts: TelegramBotOptions) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (nativeDisabledExplicit) {
|
} else if (nativeDisabledExplicit) {
|
||||||
bot.api.setMyCommands([]).catch((err) => {
|
bot.api.setMyCommands([]).catch((err) => {
|
||||||
runtime.error?.(danger(`telegram clear commands failed: ${String(err)}`));
|
runtime.error?.(danger(`telegram clear commands failed: ${String(err)}`));
|
||||||
|
|||||||
Reference in New Issue
Block a user