php - 电报机器人中是否有批量消息传递限制?
问题描述
我正在向我的所有机器人订阅者发送消息,当订阅者达到大约 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",
]);
}
解决方案
I think, the problem is caused by execution time limit in PHP. By default, the script runs for 30 seconds, but it's possible to increase it.
ini_set('max_execution_time', '600'); // Set execution time limit of 600 seconds
ini_set('max_execution_time', '0'); // Remove execution time limit
推荐阅读
- jsp - 在 JSP 中显示对象的问题
- python - 点击触摸屏后,有没有办法让 Windows 10 荣誉 pywinauto.mouse.move?
- three.js - Three.js BufferGeometry:.setAttribute 已重命名为 .setAttribute
- javascript - 嵌套数组并访问javascript中的所有其他索引
- javascript - 如何在 HQ 音频旁边录制最低比特率的屏幕共享视频?
- javascript - 音频 webaudio 类不接受带有“C:/”类型 url 的源
- android - 如何将框架添加到 Android Studio 项目?
- python - 我可以有一个无效范围的列表吗?欧拉项目#7
- google-bigquery - 如何使用通配符表语法(如 _TABLE_SUFFIX)加入 INFORMATION_SCHEMA 元数据,以便在 Google Big Query 中通过 table_name 获取结果
- kubernetes - 集群内无法访问 Kubernetes POD