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 ответов

10 просмотров

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.

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

Обсуждают сегодня

На работе пишем распределенное приложение, у которого сотни, если не тысячи настроек. Конфиги написаны на xml, расположены на разных хостах и должны быть согласованы друг с др...
Aleksandr Druzhinin
5
Мне интересно, скорее людей здесь используют D, Rust, C/C++ для решения реальных прикладных задач за деньги?)
Evil Satanson
49
Всем привет, у меня вопрос, для чего юзают D?
Sir Jiga
1
А библиотеку на D как-то можно в C/C++ использовать?
Степан
5
Я правильно понимаю что партишены раскидываются по брокерам для отзазоустойчивости и только одна партиция всегда ведущая. Остальные фоловеры?
Dmitry Bubnenkov
3
Что по дедлайну? Я бы хотел попробовать, но у меня опыта мало..
Евгений
1
а динамически увеличивать стек нельзя? а ну хотя да, откуда ты узнаешь что стек кончился...
Neko Dark Nightwolfdarkanronpa
2
хотя... яб скорее просто бы написал себе тренажёр слепой печати, стырив идеи с существующих, а потом всем бы хвастался, мол, вот вы на чем учились печатать? воот... а я себе с...
Constantin F.
5
На D нет нормальных библиотек для CLI/TUI? Для GUI куча всего и что-то даже еще обновляется, а для TUI как-то грустно..
Степан
3
Вопрос такой. Можно ли кафку считать оаспределенной хэш таблицей? Если очень упростить
Dmitry Bubnenkov
3
Карта сайта