Hi everyone. I need a help with bot conversation. I

have implemented a bot with InlineKeyboard and added allow_reentry=True option to make it possible to subscribe at the top and at the bottom. The problem is that I use user_data. Sadly, but user_data is common for all handlers and if I will work with two wizards, they both will be broken.

How can I make a separate user_data for unique instances of ConversationHandler? Thank you

11 ответов

19 просмотров

I guess you have unique conversation (entry) handlers?

Roman-Zonov Автор вопроса
Poolitzer X
I guess you have unique conversation (entry) handl...

No, the same (that’s why I have added allow_reenrtry)

Roman Zonov
No, the same (that’s why I have added allow_reenrt...

what do you need different user_data for then if its all in one conversation handler?

Roman-Zonov Автор вопроса
Poolitzer X
what do you need different user_data for then if i...

Yes, because for me (and for users) it’s two instances I don’t want to mix user_data for instances - it will break my bot

Roman Zonov
Yes, because for me (and for users) it’s two insta...

wait now you lost me, you have two instances of code running behind one bot (token)?

Roman-Zonov Автор вопроса
Poolitzer X
wait now you lost me, you have two instances of co...

Two instances of one Conversation I did it because user may start conversation, forget about it and start it again But it will not started with allow_reentry=False With allow_reentry=True, it will be started, but user_data will be mixed with old data

Roman Zonov
Two instances of one Conversation I did it because...

> With allow_reentry=True, it will be started, but user_data will be mixed with old data But if you reenter the conversation, you don't have the old states. You are back at the entry callback/its return state. So you don't have two instances of conversations, or?

Roman-Zonov Автор вопроса

But user may return to previous conversation and in that case it will be broken

Roman Zonov
But user may return to previous conversation and i...

In your entry point of the ConversationHandler reset the respective users data and starts from the blank dict

Roman-Zonov Автор вопроса
句_句 ꪜ-꠹ꪖꪗ
In your entry point of the ConversationHandler res...

But old Conversation will still work and will not be turned off So with that step (which I use for now) I reduced a risk of bug, but didn’t excluded

Roman Zonov
But old Conversation will still work and will not ...

» Old conversation will still work 🙄 Old state only will be active till the user got a reentry Once your entry point handler executed again with allow_reentry=True then previous States will be removed.

Похожие вопросы

Карта сайта