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

11 просмотров

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.

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

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

опять 25. сколько ты написал серверов, где все упиралось в вайб? не хватало тебе быстродействия, клиенты уходили и прочее? вот прямо не хватало тебе 25К запросов в секунду?
Aleksandr Druzhinin
2
Мне интересно, скорее людей здесь используют D, Rust, C/C++ для решения реальных прикладных задач за деньги?)
Evil Satanson
49
И к какой архитектуре привязана Java?
Dmitry Olshansky
17
В общем. если я беру Ди при всех его проблемах, у меня возникает первая реальная задача. Сохранения к игре, гибкие сохранения. У нас нет легкого nosql хранилища, которое можно...
Vi
10
На работе пишем распределенное приложение, у которого сотни, если не тысячи настроек. Конфиги написаны на xml, расположены на разных хостах и должны быть согласованы друг с др...
Aleksandr Druzhinin
5
а сколько всего в IT умерло? Где флеш-игры, их было туча, где они все? Сегодня технология есть, а завтра вжух и мёртвая. Этот wasm сильно напоминает джавовские апплеты, silver...
Constantin F.
5
да что то у других проектов и этого нет. нет, ну если кто-то назло кому-то специально в проектах накручивает статистику, то оно, конечно, да. Но кому это нужно, накручивать ст...
Aleksandr Druzhinin
1
сейчас сложная мысль будет: а всегда ли хороша демократия?
Serg Gini
3
а кто-нибудь занимался часами и т.п., периодически бывают некие погрешности, но у них, судя по всему, есть закономерность. В этих местах sin\cos как-то не так себя ведёт или ч...
Constantin F.
2
Я про то, что может рантайм уже портанули в wasm?
Константин Меньшиков
6
Карта сайта