mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-01-28 22:53:28 +03:00
27 lines
782 B
TypeScript
27 lines
782 B
TypeScript
import { Command, Ctx, Hears, Start, Update, Sender } from 'nestjs-telegraf';
|
|
import { UpdateType as TelegrafUpdateType } from 'telegraf/typings/telegram-types';
|
|
import { Context } from '../interfaces/context.interface';
|
|
import { HELLO_SCENE_ID } from '../app.constants';
|
|
import { UpdateType } from '../common/decorators/update-type.decorator';
|
|
|
|
@Update()
|
|
export class GreeterUpdate {
|
|
@Start()
|
|
onStart(): string {
|
|
return 'Say hello to me';
|
|
}
|
|
|
|
@Hears(['hi', 'hello', 'hey', 'qq'])
|
|
onGreetings(
|
|
@UpdateType() updateType: TelegrafUpdateType,
|
|
@Sender('first_name') firstName: string,
|
|
): string {
|
|
return `Hey ${firstName}`;
|
|
}
|
|
|
|
@Command('scene')
|
|
async onSceneCommand(@Ctx() ctx: Context): Promise<void> {
|
|
await ctx.scene.enter(HELLO_SCENE_ID);
|
|
}
|
|
}
|