- Notifications
You must be signed in to change notification settings - Fork5.7k
ConversationHandler#2802
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
There has been some discussion on related code snippet:https://pastebin.com/RxZDLyNW (see also#2802 (comment)) David ShikoHello guys!
|
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 3 comments 8 replies
-
David ShikoMessage 1.
But with using are classes we are avoiding this question because saving all data are inside an instance So maybe we want to use a classes instead of |
BetaWas this translation helpful?Give feedback.
All reactions
-
Arun Mani J
This confuses users more. Context style message passing is also available in Flask. We are providing a built in solution to avoid boilerplate messy code on users side |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
David ShikoContext is a great feature, but overkill in most cases.
|
BetaWas this translation helpful?Give feedback.
All reactions
-
Me
sure, you'll probably not need many of the attributes for many callbacks. but it comes at almost zero cost to have them. The alternative would be to go back to v11 style
Via ext.ContextTypes you can make user_data a custom class such that you can write
I don't really understand this point. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
David ShikoThe additional advantage of classes before function is structuring. I mean 2 things:
|
BetaWas this translation helpful?Give feedback.
All reactions
-
Me
I can't follow you here. what exactly do you mean by "logic", "implementation" and "menu"?
I'd argue that having multiple handlers for a state can be useful, e.g. if in a state you want to be able to handle both messages and callback queries. But you don'thave to pass mutliple states. Ofc chaning CH such that it can accept a single handlers instead of
Then I'd go back to my argument from#2802 (reply in thread) :) |
BetaWas this translation helpful?Give feedback.
All reactions
-
David ShikoMessage 2.
|
BetaWas this translation helpful?Give feedback.
All reactions
-
MeI don't understand what point you're trying to make here. What's the punshline of this message? what do you mean when you say "menu"? CH can do much more than just offer options to choose from in each step. At the very core, CH is a finite state machine (https://en.wikipedia.org/wiki/Finite-state_machine)> when the purpose is definition rather than execution
what do you mean by "internal logic"? internals of PTB? internals of CH? internals of your code? |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
David ShikoMessage 3 Message 4 (https://pastebin.com/RxZDLyNW) |
BetaWas this translation helpful?Give feedback.
All reactions
-
Mewhat I see here is mostly "abstracting your callbacks into a custom class". THat's ofc fine if it helps you keeping your code structured, but I don't see a necessity to enforce this pattern. From what I understand bound_class=User2 is supposed to mean that for each conversation, an instance of this class is created? You can achieve the same effect by doing something like
I don't fully understand what the |
BetaWas this translation helpful?Give feedback.
All reactions
-
David ShikoYes. |
BetaWas this translation helpful?Give feedback.