New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
High-level command handlers #25
Conversation
Nice point of view! Does user interaction means something like I personally think botfather approach has better UX, but it could be too complex to implement in bot framework: the number of arguments and the type of each argument varies. It should be part of business logic. The bot.Handle("/cmd", func(args []string, msg Message) {}) And how about photo/video/other-type messages? These messages seems not able to share same structure/mechanism with text messages. |
@Ronmi I think argument's parsing is not related for this issue. bot.Serve(5e9 /* timeout time.Duration */) Also middlewares may be useful in these cases, IMO. Example: bot.Use("/fun", mdllwr)
// or
bot.Handle("/fun", mdllwr, func(_ *Context){ /* do stuff */ }) As for the rest it looks good to me. |
@Ronmi I don't really think that argument parsing should be part of the library (maybeh later), cos it's quite unique to the end bot logic: e.g. do you wanna split strings by spaces or you don't? In the end there are loads of different message types, thus we shouldn't really focus on texts only. By user interaction I mean some sort of a plot, maybe in a tree-like form, which allows to build sophisticated interaction pipelines, so you don't need to do that with if's on your own. Here is a dreamy API that just came out of my head: bot.Start(startHandler)
.Get(telebot.Text, usernameHandler, errHandler)
.Get(telebot.Picture, profilePicHandler, errHandler)
.Finish(sayThanksHandler)
.Perform() So this pipeline is capable of handling "/start", asking for a username, profile picture, saying thanks after all. Again, just a trivial example out of my mind. @olebedev Yeah, we definitely should reveal timeout to public. I am still not sure we are already here to provide middleware sort of stuff :) |
I have to say sorry to you two because I'm not quite know how to express well in English. And to @tucnak specially, because I misunderstand your point. I'm not saying about to parse argument, through it would be a plus to me. I'm talking about transferring arguments. What @tucnak described in latest comment is exactly which I refer as botfather approach in my last comment. I am really sorry about I did not express it clearly. My API looks good to me, excepts lacking of "tree-form" for supporting multiple commands. I have an idea, how about a new type acts := []Action{Action{}}
acts[0].Get(telebot.Text, usernameHandler, errHandler)
.Get(telebot.Picture, profilePicHandler, errHandler)
.Finish(sayThanksHandler)
bot.Perform(acts) So we can use only two integers to determine user state. BTW, I found that travis-ci.org can set environment variables in |
Nah, wouldn't work for forks then. I am totally fine with this bot being used for testing, I hope people won't become impudent. |
👍 just to keep tabs on this issue. |
Lot's of work to do... 🎱 |
Current implementation prototype is quite dumb. All it does is primitive routing:
I still think that we should provide some handy API for "user interactipn scripts". E.g. abstract away from actual command handling and get along with "request-details-answer" sort of scripts.