You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.
I uses Telegraf + Redis-session + Stage in my bot. But session doesn't works with Promise
This very similar like this issues ( 1, 2, 3, 4 ), but nothing was helpful for me
Into my scene on "enter" event i try to set something like this: ctx.scene.state.{key} = {value}. And this work fine only if use it without promise or async function. For example:
exportconstscene=newBaseScene(MY_SCENE)// My enter scene logicscene.enter(async(ctx)=>{// this worksctx.scene.state.number=1// this set value into a state variable, but NOT save it in sessionsctx.scene.state.promise=await(newPromise<number>((resolve,reject)=>{setTimeout(()=>{resolve(1)},1000)}))console.log(ctx.scene.state)// output { number: 1, promise: 1 }// another code here...})// on any of event type will be the same behaviorscene.on('message',(ctx)=>{console.log(ctx.scene.state)// output { number: 1 }// expected to be { number: 1, promise: 1 }})
So, maybe exists the way, to trigger sync process? Or some utility function for force update the session?
I will be glad of any help, thanks!
The text was updated successfully, but these errors were encountered:
I know its been a long time, but I had similar problem, and the solution is to await ctx.scene.enter(MY_SCENE)
instead of ctx.scene.enter(MY_SCENE) without await
hope this helps
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi everyone!
I uses Telegraf + Redis-session + Stage in my bot. But session doesn't works with Promise
This very similar like this issues ( 1, 2, 3, 4 ), but nothing was helpful for me
Into my scene on "enter" event i try to set something like this:
ctx.scene.state.{key} = {value}
. And this work fine only if use it without promise or async function. For example:So, maybe exists the way, to trigger sync process? Or some utility function for force update the session?
I will be glad of any help, thanks!
The text was updated successfully, but these errors were encountered: