-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Implement scenes support #72
Comments
@VyacheslavSaloidWork I need a little time to answer this question. @all-contributors please add @VyacheslavSaloidWork for bug |
I've put up a pull request to add @VyacheslavSaloidWork! 🎉 |
Really, you can’t connect middleware by forwarding the arguments from As example: // somewhere in main.ts
const telegrafProvider = app.get('TelegrafProvider');
telegrafProvider.use(stage.middleware()); I fix that ASAP, thx. |
Now (in v1.2.0) you can connect any middleware using a Try something like that: import {
InjectBot,
Stage,
Composer,
WizardScene,
TelegrafProvider,
session,
Markup,
} from 'nestjs-telegraf';
export class AppUpdate {
constructor(@InjectBot() private readonly bot: TelegrafProvider) {
this.superWizardScene();
}
superWizardScene() {
const stepHandler = new Composer();
stepHandler.action('next', ctx => {
ctx.reply('Step 2. Via inline button');
return ctx.wizard.next();
});
stepHandler.command('next', ctx => {
ctx.reply('Step 2. Via command');
return ctx.wizard.next();
});
stepHandler.use(ctx =>
ctx.replyWithMarkdown('Press `Next` button or type /next'),
);
const superWizard = new WizardScene(
'super-wizard',
ctx => {
ctx.reply(
'Step 1',
Markup.inlineKeyboard([
Markup.urlButton('❤️', 'http://telegraf.js.org'),
Markup.callbackButton('➡️ Next', 'next'),
]).extra(),
);
return ctx.wizard.next();
},
stepHandler,
ctx => {
ctx.reply('Step 3');
return ctx.wizard.next();
},
ctx => {
ctx.reply('Step 4');
return ctx.wizard.next();
},
ctx => {
ctx.reply('Done');
return ctx.scene.leave();
},
);
const stage = new Stage([superWizard], { default: 'super-wizard' });
this.bot.use(session());
this.bot.use(stage.middleware());
}
} |
Thank you, man It's really so helpful |
Nothing helpful, it didnt work |
Hey
Tried to use scenes, but got some errors.
Scene init:
But, when i tried to enter in:
Got this one:
Cannot read property 'enter' of undefined.
The text was updated successfully, but these errors were encountered: