<?php

$bot_token = "7712681015:AAGbAzTvKnOn97pX0SgnGOYbfiP0O_QJuDE";
$admin = "7740857770"; // ADMIN TELEGRAM ID

$conn = mysqli_connect("localhost","verrifyi_unique","verrifyi_unique","verrifyi_unique");

$msg = $_GET['msg'];

$q = mysqli_query($conn,"SELECT chat_id FROM telegram_users");

while($row=mysqli_fetch_assoc($q)){

$chat_id = $row['chat_id'];

$response = file_get_contents("https://api.telegram.org/bot$bot_token/sendMessage?chat_id=$chat_id&text=".urlencode($msg)."&parse_mode=HTML");

$data = json_decode($response,true);

$message_id = $data['result']['message_id'];

mysqli_query($conn,"INSERT INTO telegram_messages(chat_id,message_id) VALUES('$chat_id','$message_id')");

}

/* ADMIN CONTROL MESSAGE */

$keyboard = [
"inline_keyboard"=>[
[
["text"=>"🗑 Delete This Broadcast","callback_data"=>"deletebroadcast"]
]
]
];

$data = [
"chat_id"=>$admin,
"text"=>"Broadcast Sent",
"reply_markup"=>json_encode($keyboard)
];

file_get_contents("https://api.telegram.org/bot$bot_token/sendMessage?".http_build_query($data));

echo "Broadcast Sent";

?>