Hi All,
I'm new born to PHP telegram bot. I've found that it is nice to support many behaviour (like inline query, inline keyboard, markdown etc..). And there is a nice example to demonstrate all of them.
However, I've found those examples are using command base (e.g.: /echo xxx, /date xxx).
What If I need to handle the user input without command base? (e.g.: user type: github, I can use webhook to get this message(of course the chat_id, user_id as well)).
Hope this question do not bother you guys.
Thanks
Mike
You can catch messages without the slash with GenericmessageCommand. Note, that the user must have a chat open with the bot.
Here is something to get you started:
https://github.com/php-telegram-bot/example-bot/blob/master/Commands/GenericmessageCommand.php
Check GenericmessageCommand.php, you'll find your answers there. )
On May 30, 2017 17:04, "mike-so" notifications@github.com wrote:
Required Information
- Operating system: Ubuntu 14.04
- PHP version: 7.0
- PHP Telegram Bot version: 0.44.1
- Using MySQL database: no
- MySQL version:
- Update Method: Webhook
- Self-signed certificate: yes
- RAW update (if available):
Hi All,
I'm new born to PHP telegram bot. I've found that it is nice to support
many behaviour (like inline query, inline keyboard, markdown etc..). And
there is a nice example to demonstrate all of them.However, I've found those examples are using command base (e.g.: /echo
xxx, /date xxx).
What If I need to handle the user input without command base? (e.g.: user
type: github, I can use webhook to get this message(of course the chat_id,
user_id as well)).Hope this question do not bother you guys.
ThanksMike
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/php-telegram-bot/core/issues/508, or mute the thread
https://github.com/notifications/unsubscribe-auth/AMhOxg-B6wX2dueyXIEQA0CSU4s5f60gks5r--mjgaJpZM4NqFGy
.
Thanks @haiksu and @chuv1!
It works fine for non-command message. 👍
However, in GenericmessageCommand->execute(), I don't understand what is the usage of the following codes. Could you guys mind to explain a bit on that cause I couldn't find any wiki/info. Thanks~
//If a conversation is busy, execute the conversation command after handling the message
$conversation = new Conversation(
$this->getMessage()->getFrom()->getId(),
$this->getMessage()->getChat()->getId()
);
//Fetch conversation command if it exists and execute it
if ($conversation->exists() && ($command = $conversation->getCommand())) {
return $this->telegram->executeCommand($command);
}
Conversation class is a FSM realisation.
A place to store your user's input between messages, for example. So if you started a conversation with a user, this code will catch users input and pass to the related command.
Check SurveyCommand.php example.
@offthegrid-mike Adding to @chuv1's answer, that code is necessary to continue a running conversation. So first we check if there is an active conversation, then, if yes, the proper command gets executed to continue the conversation.
The comments in the code snippet explain it perfectly.
Can this be closed then?
Yes, the issue is resolved, thanks @noplanman
Most helpful comment
Check GenericmessageCommand.php, you'll find your answers there. )
On May 30, 2017 17:04, "mike-so" notifications@github.com wrote: