Replies: 2 comments
-
You can use type BotContext = Context &
SessionFlavor<ScenesSessionData> &
ScenesFlavor & {
scenes_composer: ScenesComposer<any> // typing grammy always gives headaches, so use any for now
}
// replace this:
bot.use(scenes.manager())
// with:
bot.lazy(ctx => {
const scenes = new ScenesComposer<BotContext>()
// fill from the database
ctx.scenes_composer = scenes
return scenes.manager()
})
// replace this:
bot.use(scenes)
// with:
bot.lazy(ctx => ctx.scenes_composer) Perhaps, the manager could store a link to its composer to reduce this boilerplate, but the generic approach will be the same. |
Beta Was this translation helpful? Give feedback.
0 replies
-
In grammy-scenes 10.2, you can now do: // Inject ctx.scenes
bot.lazy((ctx) => {
const scenes = new ScenesComposer<BotContext>()
// Populate scenes in runtime with scenes.scene(...)
return scenes.manager()
})
bot.command("start", async (ctx) => {
// Assuming you will always have the main scene:
await ctx.scenes.enter("main")
})
// Actually run scenes
bot.lazy((ctx) => ctx.scenes.composer)
bot.start() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello @IlyaSemenov, I want to store all the scenes in the backend, there should be features for create, edit and delete a scene from the admin panel. Any ideas or examples how to do this? Can you help with it?
Beta Was this translation helpful? Give feedback.
All reactions