I created a Telegram bot using PHP, and I saved the users’ ID in user.txt, and I created a code that when the admin sends a message, the message is sent to all the users in the file, but when I send a message, the message is sent to the users at the beginning of the file, and it stops and does not send the message to all users, and continues to repeat the sending process without stopping to the users. Who sent the message to them previously, so I can stop the bot completely by closing the webhook, and this is the code used for sending.
if ($user_id == $user_id1){
$file = 'user.txt';
$handle = fopen($file, 'r');
header('Content-Type: text/plain');
header("HTTP/1.1 200 OK");
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
while (!feof($handle)) {
$send_user = fgets($handle);
sendMessage($message['text'], $send_user);
}
fclose($handle);}```
How do I make the bot send the message to all the users in the file and not just the users at the beginning of the file? I don’t want the message to be repeated.
I added it
header(“HTTP/1.1 200 OK”);
And I also added
sleep(1);
But he didn't succeed
hwbsv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.