Answer the question
In order to leave comments, you need to log in
Telegram bot and "Scripts" how to properly organize the transition between them?
On my main page, index.js takes me to the Scenegenerator file at startup (the scenes are placed there)
const currScene = new SceneGenerator();
const mainMenuScene = currScene.mainMenu(Usrmenu);
const entryMenuScene = currScene.entryMenu(arrayOfLabel);
const bot = new Telegraf(config.tgToken);
const stage = new Stage([
mainMenuScene,
entryMenuScene,
currScene.controlPanel(Botmenu, usrPanelKeyboard),
]);
bot.use(session());
bot.use(stage.middleware());
bot.command('mainMenu', (ctx) => ctx.scene.enter('mainMenu'));
bot.launch();
bot.start(async (ctx) => {
user1.checkAddUser(ctx.from);
ctx.scene.enter('entryMenu');
});
controlPanel(Botmenu, usrPanelKeyboard) {
const controlPanelScene = new Scene('controlPanel');
const BS = new BotScene();
const Botscene = new Stage([BS.controlPanelCurrBot(usrPanelKeyboard)]);
controlPanelScene.use(Botscene.middleware());
// controlPanelScene.use(() => new Stage([BotScene.mainMenu()]).middleware());
controlPanelScene.enter(async (ctx) => {
await ctx.reply(`this :\n${ctx.from.first_name} (@${ctx.from.username})`, Botmenu);
});
controlPanelScene.leave((ctx) => ctx.reply('Bye'));
// controlPanelScene.action('controlbot', (ctx) => controlPanelScene.scene.enter('BotScene'));
controlPanelScene.action('controlbot', (ctx) => ctx.scene.enter('controlCurrBot'));
controlPanelScene.on('message', (ctx) => ctx.scene.reenter());
return controlPanelScene;
}
controlPanelCurrBot(usrPanelKeyboard) {
const controlPanelScene = new Scene('controlCurrBot');
const dialog = ` №1 /change_img`;
controlPanelScene.enter(async (ctx) => {
await ctx.reply(dialog, usrPanelKeyboard);
});
controlPanelScene.leave((ctx) => ctx.reply('Bye'));
controlPanelScene.on('message', async (ctx) => ctx.reply('dialog not out'));
return controlPanelScene;
}
const stage = new Stage([
mainMenuScene,
entryMenuScene,
currScene.controlPanel(Botmenu, usrPanelKeyboard),
.....
]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question