File: /home/ngbycoco/public_html/wp-content/bo/bot.php
<?php
require_once __DIR__ . '/config.php';
$update = json_decode(file_get_contents('php://input'), true);
if (!$update) die('Invalid');
if (isset($update['message'])) {
$chatId = $update['message']['chat']['id'];
$text = $update['message']['text'] ?? '';
if (strpos($text, '/start') === 0) {
$parts = explode(' ', $text);
$ref = $parts[1] ?? '';
// ===== ساخت لینک مینیاپ =====
$appUrl = 'https://' . $_SERVER['HTTP_HOST'] . '/wp-content/bo/index.php';
if ($ref && strpos($ref, 'ref_') === 0) {
$code = substr($ref, 4);
$appUrl .= '?ref=' . $code;
}
$msg = "✦ *TonTastic*\n\n";
$msg .= "Welcome to TonTastic!\n";
$msg .= "Mine TTC tokens and earn rewards.\n\n";
if ($ref && strpos($ref, 'ref_') === 0) {
$code = substr($ref, 4);
$msg .= "🎯 You were invited with referral code: *$code*\n";
$msg .= "You'll get bonus TTC when you start mining!\n\n";
}
$msg .= "🚀 Click the button below to start mining!";
$url = "https://api.telegram.org/bot" . BOT_TOKEN . "/sendMessage";
// ===== درست ترین روش ارسال WebApp =====
$data = [
'chat_id' => $chatId,
'text' => $msg,
'parse_mode' => 'Markdown',
'reply_markup' => json_encode([
'inline_keyboard' => [
[
[
'text' => '🚀 Open App',
'web_app' => [
'url' => $appUrl
]
]
]
]
])
];
file_get_contents($url . '?' . http_build_query($data));
}
}
?>