Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using global visibility handlers #898

Open
Hambay opened this issue Aug 23, 2022 · 2 comments
Open

Using global visibility handlers #898

Hambay opened this issue Aug 23, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Hambay
Copy link
Contributor

Hambay commented Aug 23, 2022

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
Copy link
Contributor Author

Hambay commented Aug 23, 2022

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

@Hambay Hambay closed this as not planned Won't fix, can't repro, duplicate, stale Aug 23, 2022
@Hambay Hambay reopened this Aug 23, 2022
@evilsprut evilsprut added enhancement New feature or request good first issue Good for newcomers labels Aug 24, 2022
@Abror4544
Copy link

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants