Last active
April 28, 2022 00:35
-
-
Save vladthelittleone/fd9872e4a0e3c50087f0b7855d9301a2 to your computer and use it in GitHub Desktop.
Telegram Bot, using framework Telegraf.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const session = require("telegraf/session"); | |
| const Stage = require("telegraf/stage"); | |
| const WizardScene = require("telegraf/scenes/wizard"); | |
| // ... | |
| // Сцена создания нового матча. | |
| const create = new WizardScene( | |
| "create", // Имя сцены | |
| (ctx) => { | |
| ctx.reply('Этап 1: выбор типа матча.'); | |
| return ctx.wizard.next(); // Переходим к следующему обработчику. | |
| }, | |
| (ctx) => { | |
| ctx.reply('Этап 2: выбор времени проведения матча.'); | |
| return ctx.wizard.next(); // Переходим к следующему обработчику. | |
| }, | |
| (ctx) => { | |
| if (ctx.message.text === "Назад") { | |
| ctx.wizard.back(); // Вернуться к предыдущиму обработчику | |
| } | |
| ctx.reply('Этап 3: выбор места проведения матча.'); | |
| return ctx.wizard.next(); // Переходим к следующему обработчику. | |
| }, | |
| // ... | |
| (ctx) => { | |
| ctx.reply('Финальный этап: создание матча.'); | |
| return ctx.scene.leave(); | |
| } | |
| ); | |
| // Создаем менеджера сцен | |
| const stage = new Stage(); | |
| // Регистрируем сцену создания матча | |
| stage.register(create); | |
| bot.use(session()); | |
| bot.use(stage.middleware()); | |
| bot.action("create", (ctx) => ctx.scene.enter("create")); | |
| // ... |
Me too. Is Telegraf Js documentation changed?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi bro. Good day! I used your code. but I took this error:
'Failed to process updates. TypeError: Cannot read property 'enter' of undefined'