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/common": "7.5.1",
"@nestjs/core": "7.5.1", "@nestjs/core": "7.5.1",
"@nestjs/platform-express": "7.5.1", "@nestjs/platform-express": "7.5.1",
"dotenv": "^8.2.0", "dotenv": "8.2.0",
"nestjs-telegraf": "*", "nestjs-telegraf": "*",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rimraf": "3.0.2", "rimraf": "3.0.2",
"rxjs": "6.6.3", "rxjs": "6.6.3",
"telegraf": "^3.38.0" "telegraf": "3.38.0"
}, },
"devDependencies": { "devDependencies": {
"@nestjs/cli": "7.5.1", "@nestjs/cli": "7.5.1",

View File

@ -12,11 +12,13 @@ import { GreeterBotName } from './app.constants';
middlewares: [sessionMiddleware], middlewares: [sessionMiddleware],
include: [EchoModule], include: [EchoModule],
}), }),
TelegrafModule.forRoot({ TelegrafModule.forRootAsync({
name: GreeterBotName, botName: GreeterBotName,
token: process.env.GREETER_BOT_TOKEN, useFactory: () => ({
middlewares: [sessionMiddleware], token: process.env.GREETER_BOT_TOKEN,
include: [GreeterModule], middlewares: [sessionMiddleware],
include: [GreeterModule],
}),
}), }),
EchoModule, EchoModule,
GreeterModule, GreeterModule,

View File

@ -1,13 +1,21 @@
import { Telegraf } from 'telegraf'; 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 { 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'; import { Context } from '../interfaces/context.interface';
@Update() @Update()
export class EchoUpdate { export class EchoUpdate {
constructor( constructor(
@InjectBot() @InjectBot(GreeterBotName)
private readonly bot: Telegraf<Context>, private readonly bot: Telegraf<Context>,
private readonly echoService: EchoService, private readonly echoService: EchoService,
) {} ) {}