nestjs-telegraf icon indicating copy to clipboard operation
nestjs-telegraf copied to clipboard

add Composer decorator

Open Hambay opened this issue 1 year ago • 1 comments

The Composer decorator is needed for cases when it is necessary to process events regardless of the scene.

like this.

@Composer()
export class CoreComposer {
  constructor(private userService: UserService) {}

  @Start()
  async start(@Ctx() ctx: TelegramContext) {
    if (ctx.user?.isAuthenticated) {
      return ctx.scene.enter(SceneToken.WELCOME);
    } else {
      return ctx.scene.enter(SceneToken.USERNAME_INPUT);
    }
  }

  @Command('exit')
  async exit(@Ctx() ctx: TelegramContext) {
    if (ctx.user) {
      this.userService.deauthenticateUser(ctx.user.id);
    }
    ctx.session = undefined;
    return ctx.scene.enter(SceneToken.WELCOME);
  }
}

Hambay avatar Aug 25 '22 11:08 Hambay

Deploy Preview for nestjs-telegraf canceled.

Name Link
Latest commit 36dd751103eb419e1201bcbf7d4a2a4f71cda5ed
Latest deploy log https://app.netlify.com/sites/nestjs-telegraf/deploys/631057f467aeec00095fc3dc

netlify[bot] avatar Aug 25 '22 11:08 netlify[bot]