【发布时间】:2020-10-04 20:36:43
【问题描述】:
我正在向我的所有机器人订阅者发送消息,当订阅者达到大约 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",
]);
}
【问题讨论】:
-
这只是机器人中的一个示例代码,我向用户发送消息,向您展示我是如何编写代码的
标签: php telegram telegram-bot php-curl php-telegram-bot