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

Using global visibility handlers

Open Hambay opened this issue 1 year ago • 2 comments

Hi, I want to use some command and action handlers as global so that they work regardless of the user's current scene.

In my telegraph bot I implemented it like this.

export const globalCommands = new Composer<AppContext>();
globalCommands.command('start', startHandler);
globalCommands.command('exit', exitHandler);
bot.use((ctx, next) => {
  const scenes: Map<string, BaseScene<AppContext>> = stages.scenes;
  const scene = new SceneContextScene<AppContext, AppWizardSession>(
    ctx,
    scenes,
    stages.options,
  );
  ctx.scene = scene;
  return next();
});

bot.use(globalCommands);

bot.use(globalHandlers);

bot.use(stages.middleware());

How do I do this with nestjs-telegraf?

Hambay avatar Aug 23 '22 07:08 Hambay

It would be great if we had a GlobalUpdate decorator that would be processed before the scenes

Hambay avatar Aug 23 '22 08:08 Hambay

Any updates on this?

Abror4544 avatar Jan 10 '23 11:01 Abror4544