I created a functionality in my bot that allows to ping other computers, when the user pings more than 60 times the bot takes a long time to do it, and I think it does not respond to Telegram with an http 200 code, so Telegram sends it again the ping request and the loop never stops. I used this library to build my bot: https://github.com/Eleirbag89/TelegramBotPHP
The code to do it is very simple:
<?php
$telegram = new Telegram('token');
date_default_timezone_set('America/Bogota');
$chat_id = $telegram->ChatID();
$text = $telegram->Text();
$palabras = explode(" ", $text);
foreach ($palabras as $key) {
if (filter_var($key, FILTER_VALIDATE_IP)) {
$ip = $key;
$key = "";
}
if (is_numeric($key)){
$cant_paq=$key;
};
};
if (stristr($text, 'ping') && !empty($ip)) {
$numero = !empty($cant_paq) ? $cant_paq : 4;
exec("ping -c $numero $ip", $output, $status);
foreach ($output as $key) {
$resultPing .= $key . "\r\n";
}
$content = array('chat_id' => $chat_id, 'text' => $resultPing);
$telegram->sendMessage($content);
}