do not launch bot if launchOptions are defined as 'false'

This commit is contained in:
Viktor 2021-02-20 06:14:27 +03:00
parent 3d33b34841
commit 3f4b9ce4ed
2 changed files with 5 additions and 2 deletions

View File

@ -5,7 +5,7 @@ export interface TelegrafModuleOptions {
token: string; token: string;
botName?: string; botName?: string;
options?: Partial<Telegraf.Options<any>>; options?: Partial<Telegraf.Options<any>>;
launchOptions?: Telegraf.LaunchOptions; launchOptions?: Telegraf.LaunchOptions | false;
include?: Function[]; include?: Function[];
middlewares?: ReadonlyArray<Middleware<any>>; middlewares?: ReadonlyArray<Middleware<any>>;
} }

View File

@ -7,7 +7,10 @@ export async function createBotFactory(
const bot = new Telegraf<any>(options.token, options.options); const bot = new Telegraf<any>(options.token, options.options);
bot.use(...(options.middlewares ?? [])); bot.use(...(options.middlewares ?? []));
await bot.launch(options.launchOptions);
if (options.launchOptions !== false) {
await bot.launch(options.launchOptions);
}
return bot; return bot;
} }