Closed pavlentij closed 2 years ago
Hey @pavlentij ,
it is possible to skip / stop the conversation for certain incoming messages. Besides defining triggers for that inside your conversation, you can make them global like this:
$botman->hears('stop', function(BotMan $bot) {
$bot->reply('stopped');
})->stopsConversation();
This way stop
will trigger a listener from your botman route file even if you're in a conversation.
Is this what you need?
Thanks for the quick reply.
Yes, I knew about the "stop" feature, but that's not exactly what I need.
Please see the screenshot - there are two same messages were sent with the same command.
The first one didn't work because it was recognized by the system as not interactive message reply for the previous message with buttons. But the second one was working perfectly because the previous conversation (question + answer) finished, and now the command was sent through the regular list of hears.
Hmm so you want to make the first command work right? Is it part of the conversation or can the conversation be stopped after clicking the link? Do you want to continue the conversation after the first command? Then skip
could be of use for your conversation. But I guess I am not fully understanding what your goal is / what is happening in your bot.
Our logic of the bot (https://t.me/SaveDniproBot) is:
All hears for /ovd and for /ovd_place_info_2018426679 are defined in the botman.php.
Probably we have to catch these commands also in the callback function of the conversation.
I've found the way how to make it work. Maybe that's not a good solution but it's working.
There is a global config value "conversation_cache_time". If it's set to zero then the system is not storing it to the cache and during the answer for the conversation the system will not be able to find that conversation and will use global routing rules of the bot.
But for the proper for clicked buttons, we have to define all available answers for questions in the routings.
In my case all buttons have values like "/ovd_place_info_2018426679" and I have in the routes file:
$botman->hears('/ovd_place_info_([0-9]+)', BotManController::class.'@ovdPlaceConversation');
I'm sending a text message with links (like /ovd_info_12) and with two buttons "Next Page" and "Subscribe".
Now the system is waiting for the click or for some text entered.
Is there a way that if text was entered then the system will process if through the global hearing rules? Because if user clicked on the "/ovd_info_12" then it's not processed by the globally defined hear rule.