mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-01-12 07:01:26 +03:00
17 lines
412 B
TypeScript
17 lines
412 B
TypeScript
|
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) {
|
||
|
await bot.launch(options.launchOptions);
|
||
|
}
|
||
|
|
||
|
return bot;
|
||
|
}
|