I'm trying to create a script to operate my bot via Bot API, I'm using simple PHP file on my server, which has a set Webhook so that Telegram refers to this file each time when message is received. But the problem is that I'm unable to get a new message while script is already running, if I'm trying to get and assign an updated message to vary the workflow in the process I'm getting only the old message (which was present at the moment of starting script)
$update = file_get_contents('php://input');///get new data
$update = json_decode($update, TRUE);///decode data
$message = $update["message"]["text"];///assign message
switch($message) {////vary actions accordingly to first message
case "number1":
////send smth to user and wait for answer
$update = file_get_contents('php://input'); ////get new data with updated message
$update = json_decode($update, TRUE); ////decode
$message = $update["message"]["text"]; ////assign
switch($message) {////vary further actions accordingly to new message
case "number2":
////further actions
}
}
...