nestjs-telegraf/lib/utils/create-bot-factory.util.ts

17 lines
406 B
TypeScript
Raw Normal View History

import { Telegraf } from 'telegraf';
import { TelegrafModuleOptions } from '../interfaces';
export async function createBotFactory(
options: TelegrafModuleOptions,
): Promise<Telegraf<any>> {
const bot = new Telegraf<any>(options.token, options.options);
bot.use(...(options.middlewares ?? []));
if (options.launchOptions !== false) {
2022-11-30 14:57:27 +03:00
bot.launch(options.launchOptions);
}
return bot;
}