Write the bot in php for VK. The task is this: the bot write "Hello" he says "Bye", but only after 2 hours.
That's part of the code that is responsible for sending the response message if writing to him, "hi."
case strstr($message,'Hello') :
$request_params = array(
'message' => "Until",
'user_id' => $user_id,
'access_token' => $token,
'v' => '5.0'
$get_params = http_build_query($request_params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.vk.com/method/messages.send');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $get_params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);curl_close($ch); break;
If you leave everything like that, then fine – the bot works instantly respond and life is good.
How to get him to do it in an hour/two after receiving the message?
Sleep(10) – working. (but I understand that this function anywhere in the script causes it to freeze for 10 seconds)
And if you bet more, the requests begin to pour in several times, the bot can begin to send messages 3-4 times.
In what direction is there to think?