import { Scenes } from 'telegraf';
const contactDataWizard = new Scenes.WizardScene(
'CONTACT_DATA_WIZARD_SCENE_ID', // first argument is Scene_ID, same as for BaseScene
(ctx) => {
ctx.reply('What is your name?');
ctx.wizard.state.contactData = {};
return ctx.wizard.next();
},
(ctx) => {
// validation example
if (ctx.message.text.length < 2) {
ctx.reply('Please enter name for real');
return;
}
ctx.wizard.state.contactData.fio = ctx.message.text;
ctx.reply('Enter your e-mail');
return ctx.wizard.next();
},
async (ctx) => {
ctx.wizard.state.contactData.email = ctx.message.text;
ctx.reply('Thank you for your replies, we'll contact your soon');
await mySendContactDataMomentBeforeErase(ctx.wizard.state.contactData);
return ctx.scene.leave();
},
);
What i think is need
import { Scenes } from 'telegraf';
const scenarioTypeScene = new Scenes.BaseScene('SCENARIO_TYPE_SCENE_ID');
scenarioTypeScene.enter((ctx) => {
ctx.session.myData = {};
ctx.reply('What is your drug?', Markup.inlineKeyboard([
Markup.callbackButton('Movie', MOVIE_ACTION),
Markup.callbackButton('Theater', THEATER_ACTION),
]).extra());
});
scenarioTypeScene.action(THEATER_ACTION, (ctx) => {
ctx.reply('You choose theater');
ctx.session.myData.preferenceType = 'Theater';
return ctx.scene.enter('SOME_OTHER_SCENE_ID'); // switch to some other scene
});
scenarioTypeScene.action(MOVIE_ACTION, (ctx) => {
ctx.reply('You choose movie, your loss');
ctx.session.myData.preferenceType = 'Movie';
return ctx.scene.leave(); // exit global namespace
});
scenarioTypeScene.leave((ctx) => {
ctx.reply('Thank you for your time!');
});
For example i will use
telegraphjs
What we have
What i think is need