forked from telegraf/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwizard-bot.js
36 lines (34 loc) · 837 Bytes
/
wizard-bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const Telegraf = require('telegraf')
const session = require('telegraf/session')
const Stage = require('telegraf/stage')
const WizardScene = require('telegraf/scenes/wizard')
const superWizard = new WizardScene('super-wizard',
(ctx) => {
ctx.reply('Step 1')
ctx.wizard.next()
},
(ctx) => {
if (ctx.message && ctx.message.text !== 'ok') {
return ctx.replyWithMarkdown('Send `ok`')
}
ctx.reply('Step 2 ')
ctx.wizard.next()
},
(ctx) => {
ctx.reply('Step 3')
ctx.wizard.next()
},
(ctx) => {
ctx.reply('Step 4')
ctx.wizard.next()
},
(ctx) => {
ctx.reply('Done')
ctx.scene.leave()
}
)
const bot = new Telegraf(process.env.BOT_TOKEN)
const stage = new Stage([superWizard], { default: 'super-wizard' })
bot.use(session())
bot.use(stage.middleware())
bot.startPolling()