我正在向所有漫游器订阅者发送消息,而当订阅者达到约400个时,我的漫游器不会向所有机器人发送消息,但很少。我的代码在php中,并且使用过sleep()函数。
我对其进行了测试,发现在发送消息的过程中,如果1分钟内未发送消息,则发送过程将停止,并且我知道每秒发送30条消息是有限制的。
elseif ($text == '/send' && $chatID == 353575758){
$sql = $c->query("SELECT * FROM corona ORDER BY id");
$row = $sql->num_rows;
$counter = 0;
$sent = 0;
while($exe = $sql->fetch_array()) {
if($counter < 30) {
$counter++;
$sent ++;
}
else {
$sent++;
sleep(1);
$counter = 1;
$bot->sendMessage([
'chat_id' => 353575758,
'text' => $sent,
'parse_mode' => 'HTML',
]);
}
}
$bot->sendMessage([
'chat_id' => 353575758,
'text' => "Completed - sent for ".$sent." Users",
]);
}
答案 0 :(得分:1)
我认为,问题是由PHP中的执行时间限制引起的。默认情况下,脚本会运行30秒,但可以增加该脚本。
ini_set('max_execution_time', '600'); // Set execution time limit of 600 seconds
ini_set('max_execution_time', '0'); // Remove execution time limit