Revert "initial commit"

This reverts commit 2d23eba148.
This commit is contained in:
Alexander Bukhalo
2022-11-20 14:16:17 +03:00
parent 2d23eba148
commit 43816099a6
94 changed files with 17013 additions and 65 deletions

View File

@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { EchoUpdate } from './echo.update';
import { EchoService } from './echo.service';
import { RandomNumberScene } from '../greeter/scenes/random-number.scene';
@Module({
providers: [EchoUpdate, EchoService, RandomNumberScene],
})
export class EchoModule {}

View File

@@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class EchoService {
echo(text: string): string {
return `Echo: ${text}`;
}
}

View File

@@ -0,0 +1,53 @@
import { UseFilters, UseGuards, UseInterceptors } from '@nestjs/common';
import {
Help,
InjectBot,
On,
Message,
Start,
Update,
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)
private readonly bot: Telegraf<Context>,
private readonly echoService: EchoService,
) {}
@Start()
async onStart(): Promise<string> {
const me = await this.bot.telegram.getMe();
return `Hey, I'm ${me.first_name}`;
}
@Help()
async onHelp(): Promise<string> {
return 'Send me any text';
}
@Command('admin')
@UseGuards(AdminGuard)
onAdminCommand(): string {
return 'Welcome judge';
}
@On('text')
onMessage(
@Message('text', new ReverseTextPipe()) reversedText: string,
): string {
return this.echoService.echo(reversedText);
}
}