fix(sample): use new options

This commit is contained in:
Morb0 2021-01-05 13:37:00 +03:00
parent 751b15b4b2
commit f8872663d8
3 changed files with 20 additions and 10 deletions

View File

@ -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",

View File

@ -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,

View File

@ -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<Context>,
private readonly echoService: EchoService,
) {}