exit; } // ------------------------------------------------------------- // هندلر پیام‌های متنی، عکس فیش، شماره تماس // ------------------------------------------------------------- if (!isset($update['message'])) { exit; } $message = $update['message']; $from = $message['from']; $userId = (int) $from['id']; $chatId = (int) $message['chat']['id']; $text = trim($message['text'] ?? ''); $photo = $message['photo'] ?? null; $contact = $message['contact'] ?? null; $user = getUser($userId); $isNewUser = empty($user); if ($isNewUser) { // بررسی رفرال در پیام /start $referrerId = 0; if (preg_match('/^\/start\s+(?:ref_)?(\d+)$/i', $text, $mRef)) { $potentialRef = (int) $mRef[1]; if ($potentialRef !== $userId && $potentialRef > 0) { $refUser = getUser($potentialRef); if (!empty($refUser)) { $referrerId = $potentialRef; } } } $user = [ 'user_id' => $userId, 'username' => $from['username'] ?? '', 'first_name' => $from['first_name'] ?? 'کاربر', 'diamonds' => (isAdmin($userId) ? 999999999 : 0), 'is_active' => (isAdmin($userId) ? 1 : 0),