mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-10-01 04:39:32 +03:00
feat(sample): update sample
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { EchoUpdate } from './echo.update';
|
||||
import { EchoService } from './echo.service';
|
||||
import { HelloScene } from '../greeter/scenes/hello.scene';
|
||||
import { RandomNumberScene } from '../greeter/scenes/random-number.scene';
|
||||
|
||||
@Module({
|
||||
providers: [EchoUpdate, EchoService, HelloScene],
|
||||
providers: [EchoUpdate, EchoService, RandomNumberScene],
|
||||
})
|
||||
export class EchoModule {}
|
||||
|
@@ -1,20 +1,25 @@
|
||||
import { Telegraf } from 'telegraf';
|
||||
import { UseFilters, UseGuards, UseInterceptors } from '@nestjs/common';
|
||||
import {
|
||||
Ctx,
|
||||
MessageText,
|
||||
Help,
|
||||
InjectBot,
|
||||
On,
|
||||
Message,
|
||||
Start,
|
||||
Update,
|
||||
Hears,
|
||||
Command,
|
||||
} from 'nestjs-telegraf';
|
||||
import { Telegraf } from 'telegraf';
|
||||
import { EchoService } from './echo.service';
|
||||
import { GreeterBotName } from '../app.constants';
|
||||
import { Context } from '../interfaces/context.interface';
|
||||
import { ReverseTextPipe } from '../common/pipes/reverse-text.pipe';
|
||||
import { ResponseTimeInterceptor } from '../common/interceptors/response-time.interceptor';
|
||||
import { AdminGuard } from '../common/guards/admin.guard';
|
||||
import { TelegrafExceptionFilter } from '../common/filters/telegraf-exception.filter';
|
||||
|
||||
@Update()
|
||||
@UseInterceptors(ResponseTimeInterceptor)
|
||||
@UseFilters(TelegrafExceptionFilter)
|
||||
export class EchoUpdate {
|
||||
constructor(
|
||||
@InjectBot(GreeterBotName)
|
||||
@@ -33,8 +38,16 @@ export class EchoUpdate {
|
||||
return 'Send me any text';
|
||||
}
|
||||
|
||||
@Command('admin')
|
||||
@UseGuards(AdminGuard)
|
||||
onAdminCommand(): string {
|
||||
return 'Welcome judge';
|
||||
}
|
||||
|
||||
@On('text')
|
||||
onMessage(@MessageText(new ReverseTextPipe()) messageText: string): string {
|
||||
return this.echoService.echo(messageText);
|
||||
onMessage(
|
||||
@Message('text', new ReverseTextPipe()) reversedText: string,
|
||||
): string {
|
||||
return this.echoService.echo(reversedText);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user