grammyjs / conversations

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

conversation does not update the session until the conversation ends #118

Closed Yoppai closed 1 month ago

Yoppai commented 1 month ago

I'm using the golden rules of conversations but it seems that the convenience function conversion.session doesn't save the session data until the conversation is finished.

let filters = { ...data.filters, page: Math.floor(Math.random() * totalPages) + 1 };

const resDetail = await conversation.external( async () => {
    return await ineDBController.searchIne(data.telegramID, filters)
})

conversation.session.ineDB.ineData = resDetail.data
conversation.session.ineDB.menu.page = filters.page

await replyMenuToContext(inePaginationMenu, ctx, 'ine-db-pagination/')

return

When trying to send a menu from the grammy-inline-menu plugin, my error handler pops up because it tries to fill its message body with session information and that information is undefined until the session ends.

Is there any convenience function capable of refreshing the session early?

KnorpelSenf commented 1 month ago

No. You need to send your menu at a later point instead.

KnorpelSenf commented 1 month ago

(You can obviously also store things in a database instead. This will give you more control over when the data is read and written.)