I have a function which handles "/start" which enters into the wizard scene.
- Now, i have a message with the inline_keyboard with a btn called "redo".
- When i click on the "redo btn" i want is that it restarts the whole scene means it should start tha wizard again.
I have tried to do this with the redo btn
superWizard.action("redo", (ctx) => {
ctx.reply("Restarting Session!");
ctx.session = {};
ctx.scene.leave();
ctx.scene.enter("super-wizard");
});
So how can we restart the wizard scene?
I tried this below code too
return ctx.wizard.selectStep(0);
Still this is not working, Below is my full code.
const superWizard = new Scenes.WizardScene(
"super-wizard",
(ctx) => {
...
return ctx.wizard.next();
},
(ctx) => {
...
return ctx.wizard.next();
},
(ctx) => {
...
return ctx.wizard.next();
},
(ctx) => {
bot.telegram.sendMessage(ctx.chat.id, `Perform Action`, {
reply_markup: {
inline_keyboard: [
[
{ text: "Confirm & Send!", callback_data: "confirm" },
{ text: "Redo!", callback_data: "redo" },
{ text: "Stop!", callback_data: "stop" },
],
],
},
});
}
}
);
superWizard.action("redo", (ctx) => {
ctx.reply("Restarting Session!");
ctx.session = {};
ctx.wizard.selectStep(0);
});
Please provide some help.