Merge pull request #281 from toolstik/feature/optional-launch

do not launch bot if launchOptions are defined as 'false'
This commit is contained in:
Alexander Bukhalo
2021-02-21 01:41:50 +03:00
committed by GitHub
2 changed files with 5 additions and 2 deletions

View File

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

View File

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