-
-
Notifications
You must be signed in to change notification settings - Fork 960
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
Parallel commands #1451
Comments
As far as i could see in the example command GenericmessageCommand.php of the Conversation Example, there exists the function to check if an conversation is active, on line 79 you should be able to add this check to your conversation command and give the user the appropriate warning/message |
If I understand this correctly GenericMessageCommand is not executed on commands, only on messages. So if you send something like /someConv GenericCommand will be executed only if SomeConvCommand not found and GenericmessageCommand won't be executed at all. |
That is true. I mentioned that file because it has already an example how you can build a check into your Conversation Command to check if a conversation is already ongoing |
When should I use this method? If I put it inside a command, it will only be executed after another conversation (different command) has already been cancelled. |
you could make a check within a conversation command , something like this
you can also use |
If I am reading this correctly, calling conversation constructor cancels other last active conversation https://github.com/php-telegram-bot/core/blob/57a649cfcfe35883165c19942b460ea6b2dfd606/src/Conversation.php#L119C8-L123C1 Consider this use case:
$message->getText approach should work fine but it requires fetching conversations from db and comparing to current in all conversations I implement. If GenericCommand were always executed before specific command, we could implement common logic between all commands there. |
you are right. it seems that way. but we can "just" copy the check from the file itself and do something like this !the code was not tested! $conversation = ConversationDB::selectConversation($this->user_id, $this->chat_id, 1);
if (isset($conversation[0])) {
//Pick only the first element
$this->conversation = $conversation[0];
if ($this->name !== $this->conversation['command']) { //check if the command name in $name matches the command name in the conversation
//return message that another conversation is active. possible to send the user the command name with $this->conversation['command']
}
//continue with the command file if the check above results in a matching command name
}
|
Any updates on this #1102 (comment)?
My problem is that my bot has multiple conversation commands, and I want to explicitly notify user that older conversation is going to be canceled. GenericCommand only runs if no other command is found. So far I can't find any solution to this.
Am I missing something here?
The text was updated successfully, but these errors were encountered: