问题描述
我在我的 bot 中创建了一个功能,允许 ping 其他计算机,当用户 ping 超过 60 次时,bot 需要很长时间才能完成,而且我认为它不会使用 http 200 代码响应 Telegram,因此 Telegram 再次发送 ping 请求,循环永不停止。我使用这个库来构建我的机器人:https://github.com/Eleirbag89/TelegramBotPHP
代码很简单:
<?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);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)