-
-
Notifications
You must be signed in to change notification settings - Fork 963
Feature/smartinterface #104
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
Feature/smartinterface #104
Conversation
Regarding the new
Also, it would be great if we could find out if the bot is an admin of the entered channels before showing the channel selection keyboard, so it doesn't go through all the steps and at the end it says "Sorry, can't send...". Can the Telegram keyboard be set to accept multiple selections like checkboxes? Would be cool to add that when managing multiple channels, to allow the same message to be sent to multiple ones 😃 Similarly, if there is only one channel, it should select it automatically I think. For now I've just had a look at this, will check out the main conversation feature soon 👍 |
$state = $session['state']; | ||
} | ||
|
||
$channels = $this->getConfig('your_channel'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before continuing, make sure that at least one channel has been set in the config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Correct typos and minor code styling.
Allow backwards compatibility when managing only one channel.
@MBoretto Great work so far, it's coming along really nicely!! After combing through the code and trying different things, here a few thoughts I've come up with so far. Let me know what you think! Multiple parallel conversationsWhen mixing different conversations, any old one is set to
The way the commands work at the moment, it's not possible to send SubcommandsWould it be an idea to add subcommands to conversations to make it easier to control or alter them?
This could obviously be used for other stuff too. Short-handsIt might be an idea to consider short-hand commands for the conversations.
This specific example doesn't allow images or other media, just text. Other conversation commands could implement their own versions if they wanted them. |
Multiple parallel conversationI prefer to avoid this, because user don't care about what is typing in the chat. Can happen that the user jumps between commands and start nesting conversation.
Subcommands & short-handsAs ux designer (we can talk about ux design in bot??) :) , I think that commands just have to be pressed. Adding params increase the complexity for the mean user in bot interaction. But! We can have care, as you said, that all commands can work both with conversation and paramar (at least in minimal function).
|
$this->chat_id = $chat_id; | ||
$this->command = $command; | ||
|
||
$this->command_is_provided = (is_null($command)) ? false : true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assigning true
or false
explicitly doesn't make sense.
Instead, it's easier to just put:
$this->command_is_provided = isset($command);
or (which is faster performance-wise)
$this->command_is_provided = ($command !== null);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will fix it
Apart from the few things I commented on inline above, I think we're good to go 😃 I'll see if I can manage to write some tests for this before we merge. Nice work 👍 |
Some typo corrections.
I put the var to public because it seem's to me easy to menage, like the var $_SESSION. That's all! |
I'm busy writing some tests and have come across a few things we need to discuss.
Remember, KISS 😉 The simpler it all is, the easier it is to test and maintain. When making changes to something that already works as it should, please explain why exactly you're changing it. That way we can discuss and possibly improve it. |
IntroI'm still thinking about a way to break in piece the long
Inside the class the fetched data are stored twice.
What I like about this implementation is:
Answers
Further next things in mindI would like to create a protected var for each database column instead of store everything here: https://github.com/MBoretto/php-telegram-bot/blob/feature/smartinterface/src/Conversation.php#L26 Sorry for this long comment, I hope I have clarified my latest change in this feature! |
Data management Looking at the pseudo code, I really like the first line to load a conversation. I had thought about this already but left it as you had first implemented it. Like the example, I think it's better to have a static method ( Do you think this is a good idea? I totally agree with you on trying to keep database queries to an absolute minimum. We can do this by having the if ($conversation = Conversation::load($user_id, $chat_id)) {
$conversation->stop();
$conversation->update();
} Obviously only the About having 2 methods,
I think if we introduce good getter/setter methods, this isn't necessary. What would be the advantage of this? Hope I responded to all your point in some way. |
reintroduced update()
…elling a conversation.
When the command ends, the last step should be to actually "stop" it, not before, as some data already goes lost when stopping the conversation.
…php-telegram-bot into feature/smartinterface
Small cleanup fixes
Add conversation tests and a few matching helpers.
I renamed the known
tracking
feature withconversation
. With this new name every thing is more readable.I test a lot and seem that works fine, and i would like to have a feeedback also from you guy @akalongman @noplanman before continue.
Here some things to know