grammyjs / conversations

Conversational interfaces for grammY.
https://grammy.dev/plugins/conversations
MIT License
48 stars 17 forks source link

feat: drop update when calling `skip` #43

Closed KnorpelSenf closed 2 years ago

KnorpelSenf commented 2 years ago

Currently, doing await conversation.skip() has the effect that the conversation will not handle the update. Instead, it returns control to the underlying middleware system, which will continue processing the update. This behaviour is what enables parallel conversations, i.e. having multiple conversations in the same chat with different people.

However, in some cases it is desirable to simply drop the update when skipping it, rather than letting the middleware handle it. It would therefore be great to be able to pass { drop: true } to conversation.skip which does exactly that. In other words, await conversation.skip({ drop: true }) still rewinds the logs but also consumes the update, the same way an empty handler () => {} would.

In turn, this property should be upstreamed to conversation.waitUntil and the like as well as to forms. This would allow to do

await ctx.reply("Send some text")
const text = await conversation.form.text({ drop: true })

which would return the text if sent, and simply drop everything else (photos, callback queries, etc).

KnorpelSenf commented 2 years ago

Please review #51.