From f8872663d888c818bebf7e9deb9e763cf3585c4a Mon Sep 17 00:00:00 2001 From: Morb0 Date: Tue, 5 Jan 2021 13:37:00 +0300 Subject: [PATCH] fix(sample): use new options --- sample/01-complete-app/package.json | 4 ++-- sample/01-complete-app/src/app.module.ts | 12 +++++++----- sample/01-complete-app/src/echo/echo.update.ts | 14 +++++++++++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/sample/01-complete-app/package.json b/sample/01-complete-app/package.json index 8ccfff6..32a925d 100644 --- a/sample/01-complete-app/package.json +++ b/sample/01-complete-app/package.json @@ -23,12 +23,12 @@ "@nestjs/common": "7.5.1", "@nestjs/core": "7.5.1", "@nestjs/platform-express": "7.5.1", - "dotenv": "^8.2.0", + "dotenv": "8.2.0", "nestjs-telegraf": "*", "reflect-metadata": "0.1.13", "rimraf": "3.0.2", "rxjs": "6.6.3", - "telegraf": "^3.38.0" + "telegraf": "3.38.0" }, "devDependencies": { "@nestjs/cli": "7.5.1", diff --git a/sample/01-complete-app/src/app.module.ts b/sample/01-complete-app/src/app.module.ts index 667774f..408a307 100644 --- a/sample/01-complete-app/src/app.module.ts +++ b/sample/01-complete-app/src/app.module.ts @@ -12,11 +12,13 @@ import { GreeterBotName } from './app.constants'; middlewares: [sessionMiddleware], include: [EchoModule], }), - TelegrafModule.forRoot({ - name: GreeterBotName, - token: process.env.GREETER_BOT_TOKEN, - middlewares: [sessionMiddleware], - include: [GreeterModule], + TelegrafModule.forRootAsync({ + botName: GreeterBotName, + useFactory: () => ({ + token: process.env.GREETER_BOT_TOKEN, + middlewares: [sessionMiddleware], + include: [GreeterModule], + }), }), EchoModule, GreeterModule, diff --git a/sample/01-complete-app/src/echo/echo.update.ts b/sample/01-complete-app/src/echo/echo.update.ts index ad31f76..1d0d6b3 100644 --- a/sample/01-complete-app/src/echo/echo.update.ts +++ b/sample/01-complete-app/src/echo/echo.update.ts @@ -1,13 +1,21 @@ import { Telegraf } from 'telegraf'; -import { Command, Help, InjectBot, On, Start, Update } from 'nestjs-telegraf'; +import { + Command, + getBotToken, + Help, + InjectBot, + On, + Start, + Update, +} from 'nestjs-telegraf'; import { EchoService } from './echo.service'; -import { HELLO_SCENE_ID } from '../app.constants'; +import { GreeterBotName, HELLO_SCENE_ID } from '../app.constants'; import { Context } from '../interfaces/context.interface'; @Update() export class EchoUpdate { constructor( - @InjectBot() + @InjectBot(GreeterBotName) private readonly bot: Telegraf, private readonly echoService: EchoService, ) {}