grammyjs / conversations

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

How to wait external data change? #121

Closed swim2sun closed 1 month ago

swim2sun commented 1 month ago

If I want to wait util some data changed in database, how can I do it in conversations?

KnorpelSenf commented 1 month ago

There is no way to do that.

Conversations are stored in the session data. Session data is only available during update handling. You can technically access the underlying storage directly, but this causes race conditions and may corrupt you're session data, which in turn means that you'll break the conversations plugin.

Conversations 2.0 are almost complete now. They no longer rely on sessions. Instead, they use an independent storage. They also expose a method that lets you resume your conversation manually based on external events. This has been planned since #19.

It is already implemented on the engine branch so you could do

npm install github:grammyjs/conversations#engine

and by the first one to try it. Note, however, that it's currently completely undocumented. This will naturally change in the coming time.

Please leave feedback if you end up trying it out.

I will close this in favour of #19 but if you have further questions, ask away.