refactor(): extract bot instace factory

This commit is contained in:
Morb0
2021-01-03 13:04:53 +03:00
parent 34070fcf68
commit d48123ea38
2 changed files with 22 additions and 37 deletions

View File

@@ -0,0 +1,13 @@
import { Telegraf } from 'telegraf';
import { TelegrafModuleOptions } from '../interfaces';
export async function createBotFactory(
options: TelegrafModuleOptions,
): Promise<Telegraf<never>> {
const bot = new Telegraf<never>(options.token, options.options);
bot.use(...(options.middlewares ?? []));
await bot.launch(options.launchOptions);
return bot;
}