EdJoPaTo / grammy-inline-menu

Inline Menus for Telegram made simple. Successor of telegraf-inline-menu.
MIT License
352 stars 45 forks source link

Add scene / wizard feature #31

Open sfarzoso opened 5 years ago

sfarzoso commented 5 years ago

Hi,

I would like to know if you're interested to add an important functionality to your menu library: the wizard. Some days ago I asked you how to configure properly your library with the WizardScene of TelegrafJS framework. The problem with the WizardScene is that we can't await a result from it, and this will cause a lot of problem with some functionality of your library, in particular with the replyMenuMiddleware.

So essentially if I need to start a wizard and then display the menu back at the end I can't.

I saw that in your library there is the question functionality, unfortunately this doesn't fit as a real wizard, and also when I used it in my code the bot has lost the commands configured with bothfather (don't know if is a bug or I implemented wrong).

Anyway, will be nice if you include something like a wizard that is fully compatible with your library. I know that probably you are busy, and I'm too, but I can help you to integrate this feature if you need some help. Also, I saw that TelegrafJS has crafted the WizardScene using Composer, so most likely we are talking about extending the functionality of a class and customizing it.

The wizard feature it may seems stupid or unnecessary, but trust me that in a real production environment, especially for a business bot is it's incredibly necessary.

I hope you will consider this feature to improve your library and make it substantially the best available on the square.

Thanks for the attention.

EdJoPaTo commented 5 years ago

also when I used it in my code the bot has lost the commands configured with bothfather (don't know if is a bug or I implemented wrong)

As bots can't interact with the botfather (as far as I know) they can't set their commands shown in the Telegram Client GUI. Something I can think of is a /command getting ignored by your bot. Telegraf does everything from the front to the back. When the Telegraf bot.command(…) is defined after the menu.init() and your command was a reply to the question the menu gets the text and handles it instead of the later defined Telegraf bot.command(…). Maybe that is what happened there. If not and you can reproduce your problem please supply an issue for that :)

Back to your initial question: The Scene / Wizard is doing control flow in order to get to a next step based on what's already supplied. (Kinda like requested with #12 but at a bigger scope).

Currently I am thinking of something like that: Based on the checks (the user still has to implement for their needs) the current step is known. The menu text and buttons are shown according to the current step.

I think forcing the user to advance to the next step when he fulfilled every part of the current step is a bad idea. Having "back" / "continue" / "finish" buttons will be easier to understand for users I think. (Also there has to be made sure the user understands "menu up back" is a different "back" than the "go a step back")

With my current thought this might result in major refactoring and probably breaking changes.

sfarzoso commented 5 years ago

@EdJoPaTo the bot command can be set through bothfather, I mean the command available in the GUI not behind code. Anyway, this is not the point of the question. I would make a logic similar to this, if you try their bot, you can see that there is the menu wizard like your library and something like a wizard scene which handle all the user inputs. Tell me if is possible make something like that.

EdJoPaTo commented 4 years ago

Investigate (still a TODO): It should be possible to create something like an InlineWizzard based on MenuLike that will be introduced with version 5.