Conversation
It's gross but it works?
|
Okay, I've implemented one method of having a |
Singletons are quite frankly gross and requiring the user to initialize their menus shouldn't be a huge deal Also remove str_type stuff since it was unused Add a id_from_update method since it was used in several places but looked incredibly gross as a "oneliner"
Also rename the name parameter of buttons to uuid to better detail what it does, and allow the toggle and radio buttons to have names seperate from their uuid Pass update around (unfortunately many properties aren't properties anymore) Add a post_init method to buttons that are called after they've gotten assigned their parent_menu attribute
|
Okay, I've added what I think would be the best way to have toggle and radio buttons. Please see the example bot (menubot.py) for implementation.
The way I see it is that if we get persistence (#638) then 1. isn't a big problem. (there's another problem with how to handle if the bot author changes their menus... and therefore their uuids) |
# Conflicts: # telegram/ext/handler.py
|
@bomjacob I'm motivated to check this out, but I'm getting some weird errors with the example code. I merged master, could you check if it's still running good for you? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
# Conflicts: # telegram/ext/handler.py
# Conflicts: # telegram/ext/handler.py
|
I've fixed a lot of my issues by reworking it to use the factory patterns (still not sure I like it better though... thoughts?). And once we resolve #1017 and #1080 I think it might be good enough. |
|
Great this gets attention again :) I'm gonna check it out |
|
So the way I see it there are fundementally 4 ways of doing inline menus.
Therefore I have decided to close this PR, since which one of these methods are best is very application dependent (method one is great for some things - botfather even seems to use something similar) I have implemented a very rough version of method 4 in my latest project. Mostly cause it seemed fun to try, and was the method with the (in my opinion) fewer cons. See menu.py, utils.py for the data link encoding algorithm, and settings.py for usage. |
|
Telegram now checks if the inline data you send actually originated from a bots's inline keyboard button, thus options 1 and 2 (due to security concerns) are irrelevant. I can't judge on 3 vs. 4 |
Not yet completed but I would like some feedback :)
This adds the ability to create Menus that are navigable using InlineKeyboards.
Please see menubot.py for how I'd like it to work. Currently only normal Buttons (that work much like InlineKeyboardButton but with menu support) are implemented, but I'd like it to have a ToggleButton and a RadioButton too. This should work via chat_data and/or user_data, but I can't think of which cases it should use one or the other (or maybe it should be up to the user?), so I'd like some help with this :)
There's another problem with this currently, and that is that since we currently don't have any persistence implemented (#638), if you restart the bot, then old menus will no longer work. This can be curcumvented currently by giving each Button a unique
nameattribute that will be used instead of UUIDs, but while that works for now, when we implement persistence, this should be updated.If you have any questions and/or comments as to how you'd like this implemented, please comment below or contact me on telegram @bomjacob.