Naively Programmable Module
Wondering what’s next for npm?Check out our public roadmap! »

telegraf-better-stage

1.0.1 • Public • Published

Telegraf Better Stage

Telegraf.js stage with sequential transition between scenes

Installation

npm

npm i telegraf-better-stage --save

yarn

yarn add telegraf-better-stage

Usage

Just replace

const Stage = require('telegraf/stage')

with

const Stage = require('telegraf-better-stage')

And now you can you this stage as default telegraf stage, but you have new cool methods:

ctx.scene.next

Enter to the next scene

const scene1 = new Scene('scene1')
    .enter((ctx) => ctx.scene.next())

const scene2 = new Scene('scene2')
    .enter((ctx) => ctx.reply('Scene 2'))

const stage = new Stage([
    scene1, // first scene
    scene2, // next scene
])

bot.use(stage.middleware())

ctx.scene.back

Enter to the previous scene

ctx.scene.enter

New way to enter the scene

const scene1 = new Scene('scene_first')
    .enter(Composer.reply('Scene 1'))

const scene2 = new Scene('scene_second')
    .enter(Composer.reply('Scene 2'))

bot.start(Stage.enter(scene1)) // instead of using id bot.start(Stage.enter('scene_first'))

Install

npm i telegraf-better-stage

DownloadsWeekly Downloads

6

Version

1.0.1

License

MIT

Unpacked Size

3.93 kB

Total Files

5

Last publish

Collaborators

  • avatar