mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-10-02 20:50:11 +03:00
16
lib/utils/create-bot-factory.util.ts
Normal file
16
lib/utils/create-bot-factory.util.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user