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
The code below doesn't work correctly, most likely it breaks the side effect system, but based on the documentation, this behavior is not obvious. I managed to fix it by wrapping counter in external:counter = await conv.external(counter - 1).
asyncfunctioncounter(conv: Conversation,ctx: Context){awaitctx.reply('Please send me a message');letcounter=0;while(true){conv.log(`Loop begin: Counter: ${counter}`);consttext=awaitconv.form.text();conv.log(`After wait: Counter: ${counter}`);constidx=conv.session.tags.indexOf(text);if(idx!==-1){conv.log(`Remove "${text}" at ${idx} index`);conv.session.tags.splice(idx,1);counter--;}else{conv.log(`Add "${text}"`);conv.session.tags.push(text);counter++;}awaitctx.reply(`Counter: ${counter}`);if(counter===3){awaitctx.reply('Done');return;}conv.log(`Loop end: Counter: ${counter}`);}}
Logs:
Loop begin: Counter: 0
After wait: Counter: 0
Add "1"
Loop end: Counter: 1
Loop begin: Counter: 1
After wait: Counter: 1
Remove "1" at 0 index
Loop end: Counter: 0
Loop begin: Counter: 0
After wait: Counter: -2 <--- Unexpected after wait
Add "1"
Loop end: Counter: -1
Loop begin: Counter: -1
[Stuck, no more interactions work]
The text was updated successfully, but these errors were encountered:
The code below doesn't work correctly, most likely it breaks the side effect system, but based on the documentation, this behavior is not obvious. I managed to fix it by wrapping counter in external:
counter = await conv.external(counter - 1)
.Logs:
The text was updated successfully, but these errors were encountered: