From 3f4b9ce4ede424734ad92e93fc62fca32567070a Mon Sep 17 00:00:00 2001 From: Viktor Date: Sat, 20 Feb 2021 06:14:27 +0300 Subject: [PATCH] do not launch bot if launchOptions are defined as 'false' --- lib/interfaces/telegraf-options.interface.ts | 2 +- lib/utils/create-bot-factory.util.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/interfaces/telegraf-options.interface.ts b/lib/interfaces/telegraf-options.interface.ts index 7fccf05..f8f6b74 100644 --- a/lib/interfaces/telegraf-options.interface.ts +++ b/lib/interfaces/telegraf-options.interface.ts @@ -5,7 +5,7 @@ export interface TelegrafModuleOptions { token: string; botName?: string; options?: Partial>; - launchOptions?: Telegraf.LaunchOptions; + launchOptions?: Telegraf.LaunchOptions | false; include?: Function[]; middlewares?: ReadonlyArray>; } diff --git a/lib/utils/create-bot-factory.util.ts b/lib/utils/create-bot-factory.util.ts index 5eb4f8f..f1ae787 100644 --- a/lib/utils/create-bot-factory.util.ts +++ b/lib/utils/create-bot-factory.util.ts @@ -7,7 +7,10 @@ export async function createBotFactory( const bot = new Telegraf(options.token, options.options); bot.use(...(options.middlewares ?? [])); - await bot.launch(options.launchOptions); + + if (options.launchOptions !== false) { + await bot.launch(options.launchOptions); + } return bot; }