0, "ref"=>0, "vip_until"=>0, "free_vip_used"=>false ]; } // ================= /START ================= if(strpos($text,"/start") === 0){ if(!checkJoin($chat_id)){ bot('sendMessage',[ 'chat_id'=>$chat_id, 'text'=>"❗ Botdan foydalanish uchun kanalga aʼzo bo‘ling:\n\n$required_channel", 'reply_markup'=>json_encode([ 'inline_keyboard'=>[ [['text'=>"📢 Kanalga o‘tish",'url'=>"https://t.me/".str_replace("@","",$required_channel)]], [['text'=>"🔄 Tekshirish",'callback_data'=>"check_join"]] ] ]) ]); exit; } // 🎁 FREE VIP 1 KUN (1 marta) if($data[$chat_id]['free_vip_used'] == false){ $data[$chat_id]['vip_until'] = time() + 86400; $data[$chat_id]['free_vip_used'] = true; } save($data); $keyboard = [ 'keyboard'=>[ [['text'=>"💰 Balans"],['text'=>"🔐 VIP"]], [['text'=>"🎬 Kino"],['text'=>"⚽ Sport"]], [['text'=>"🎵 Muzika"],['text'=>"🧸 Multfilm"]], [['text'=>"📰 Yangiliklar"],['text'=>"😂 Ko‘ngilochar"]], [['text'=>"🏠 Mahalliy"],['text'=>"🌐 Barcha kanal"]] ], 'resize_keyboard'=>true ]; bot('sendMessage',[ 'chat_id'=>$chat_id, 'text'=>"👋 Xush kelibsiz!\n🎁 Sizga 1 kunlik VIP bepul berildi!", 'reply_markup'=>json_encode($keyboard) ]); exit; } // ================= CHECK JOIN CALLBACK ================= if($callback && $callback['data']=="check_join"){ $chat_id = $callback['message']['chat']['id']; if(checkJoin($chat_id)){ bot('answerCallbackQuery',[ 'callback_query_id'=>$callback['id'], 'text'=>"✅ Tasdiqlandi!" ]); bot('sendMessage',[ 'chat_id'=>$chat_id, 'text'=>"🎉 A’zo bo‘ldingiz! Endi bot ishlaydi.\n/start ni bosing." ]); } else { bot('answerCallbackQuery',[ 'callback_query_id'=>$callback['id'], 'text'=>"❌ Hali a’zo emassiz!", 'show_alert'=>true ]); } exit; } // ================= BALANS ================= if($text == "💰 Balans"){ $link = "https://t.me/".$bot_username."?start=".$chat_id; bot('sendMessage',[ 'chat_id'=>$chat_id, 'text'=>"💰 Balans: ".$data[$chat_id]['balance']." so‘m\n👥 Ref: ".$data[$chat_id]['ref']."\n\n🔗 Link:\n$link" ]); } // ================= VIP ================= if($text == "🔐 VIP"){ $vip = ($data[$chat_id]['vip_until'] > time()); if($vip){ $buttons = []; foreach($channels['vip'] ?? [] as $c){ $buttons[] = [[ 'text'=>$c['name'], 'url'=>$c['url'] ]]; } bot('sendMessage',[ 'chat_id'=>$chat_id, 'text'=>"🔥 VIP ACTIVE\n⏳ Tugash: ".date("Y-m-d H:i",$data[$chat_id]['vip_until']), 'reply_markup'=>json_encode(['inline_keyboard'=>$buttons]) ]); exit; } bot('sendMessage',[ 'chat_id'=>$chat_id, 'text'=>"🔐 VIP narx: 300 so‘m\n💵 Balans: ".$data[$chat_id]['balance'], 'reply_markup'=>json_encode([ 'inline_keyboard'=>[ [['text'=>"💎 VIP olish",'callback_data'=>"buy_vip"]] ] ]) ]); } // ================= BUY VIP ================= if($callback && $callback['data']=="buy_vip"){ $chat_id = $callback['message']['chat']['id']; if($data[$chat_id]['balance'] < 300){ bot('answerCallbackQuery',[ 'callback_query_id'=>$callback['id'], 'text'=>"❌ Pul yetarli emas", 'show_alert'=>true ]); exit; } $data[$chat_id]['balance'] -= 300; $data[$chat_id]['vip_until'] = time() + (7*86400); save($data); bot('answerCallbackQuery',[ 'callback_query_id'=>$callback['id'], 'text'=>"🎉 VIP yoqildi!" ]); exit; } // ================= CHANNEL MENU ================= function menu($chat_id,$channels,$key,$title){ if(empty($channels[$key])){ bot('sendMessage',[ 'chat_id'=>$chat_id, 'text'=>"❌ Bo‘lim bo‘sh" ]); return; } $buttons = []; foreach($channels[$key] as $c){ $buttons[] = [[ 'text'=>$c['name'], 'url'=>$c['url'] ]]; } bot('sendMessage',[ 'chat_id'=>$chat_id, 'text'=>$title, 'reply_markup'=>json_encode(['inline_keyboard'=>$buttons]) ]); } // ================= SECTIONS ================= if($text=="🎬 Kino") menu($chat_id,$channels,"kino","🎬 Kino"); if($text=="⚽ Sport") menu($chat_id,$channels,"sport","⚽ SPORT telekanallar roʻyhati. ⬇️"); if($text=="🎵 Muzika") menu($chat_id,$channels,"music","🎵 Muzika"); if($text=="🧸 Multfilm") menu($chat_id,$channels,"cartoon","🧸 Multfilm"); if($text=="📰 Yangiliklar") menu($chat_id,$channels,"news","📰 Yangiliklar"); if($text=="😂 Ko‘ngilochar") menu($chat_id,$channels,"fun","😂 Ko‘ngilochar"); if($text=="🏠 Mahalliy") menu($chat_id,$channels,"local","🏠 Mahalliy"); // ================= ALL CHANNELS ================= if($text=="🌐 Barcha kanal"){ $all = []; foreach($channels as $type=>$list){ if($type=="vip") continue; foreach($list as $c){ $all[] = $c; } } $buttons = []; foreach($all as $c){ $buttons[] = [[ 'text'=>$c['name'], 'url'=>$c['url'] ]]; } bot('sendMessage',[ 'chat_id'=>$chat_id, 'text'=>"🌐 Barcha kanallar", 'reply_markup'=>json_encode(['inline_keyboard'=>$buttons]) ]); } save($data); ?>