Download index.js from Reoo88/Docker: direct link, hf CLI and curl.
- Browser
- Download file 4.75 kB
-
https://huggingface.co/spaces/Reoo88/Docker/resolve/main/index.js
- Command line
-
hf download hf://spaces/Reoo88/Docker/index.js
-
curl -L -o index.js https://huggingface.co/spaces/Reoo88/Docker/resolve/main/index.js
4.75 kB
| const { WebcastPushConnection } = require('tiktok-live-connector'); | |
| const axios = require('axios'); | |
| const dns = require('dns'); | |
| // --- الإعدادات ⚙️ --- | |
| const TIKTOK_USERNAME = "ah_md107"; | |
| const TELEGRAM_TOKEN = "8576498050:AAHB51H9vLwFhDUFqYWttPaSa5qhPLzQVWE"; | |
| const TELEGRAM_CHAT_ID = "-1002856018359"; | |
| dns.setServers(['8.8.8.8']); | |
| // --- المتغيرات الحسابية 📊 --- | |
| let highestHundred = 0; // لتتبع إشعارات الصعود | |
| let maxViewers = 0; // لأعلى رقم حقيقي | |
| let totalLikes = 0; // إجمالي الإعجابات | |
| let totalGifts = 0; // إجمالي عدد الهدايا | |
| let topGifterName = "لا يوجد"; | |
| let maxGiftCoins = 0; // لتحديد أكبر داعم | |
| async function sendToTelegram(text) { | |
| try { | |
| const addrs = await new Promise(r => dns.resolve4('api.telegram.org', (e, a) => r(a))); | |
| await axios.post(`https://${addrs[0]}/bot${TELEGRAM_TOKEN}/sendMessage`, { | |
| chat_id: TELEGRAM_CHAT_ID, | |
| text: text, | |
| parse_mode: 'HTML', | |
| disable_web_page_preview: false | |
| }, { headers: { 'Host': 'api.telegram.org' } }); | |
| } catch (e) { console.log("خطأ في التلجرام"); } | |
| } | |
| let tiktokConnection = new WebcastPushConnection(TIKTOK_USERNAME, { | |
| processInitialData: true, | |
| enableWebsocketUpgrade: true, | |
| clientParams: { | |
| "app_language": "en-US", | |
| "apiKey": "Euler_Y2FlYTIyODYzNDQ0OTcxZjYyNGExZTkyMDM2NTMwZWE1ZjUzYmZmMDVmMGNlYjg0YzkzY2Vk" | |
| } | |
| }); | |
| // 1. إشعار بداية البث 🚀 | |
| tiktokConnection.connect().then(state => { | |
| // تصفير البيانات لكل بث جديد | |
| highestHundred = 0; maxViewers = 0; totalLikes = 0; totalGifts = 0; | |
| topGifterName = "لا يوجد"; maxGiftCoins = 0; | |
| const liveLink = `https://www.tiktok.com/@${TIKTOK_USERNAME}/live`; | |
| sendToTelegram(`🚀 <b>بدأ البث المباشر الآن!</b>\n👤 الحساب: <code>${TIKTOK_USERNAME}</code>\n🔗 الرابط: ${liveLink}`); | |
| }).catch(err => console.log("بحث...")); | |
| // 2. مراقبة المشاهدين والصعود 🏔️ | |
| tiktokConnection.on('roomUser', (data) => { | |
| const viewers = data.viewerCount; | |
| const liveLink = `https://www.tiktok.com/@${TIKTOK_USERNAME}/live`; | |
| // تحديث أعلى رقم حقيقي | |
| if (viewers > maxViewers) maxViewers = viewers; | |
| // منطق إشعارات المئات (صعود فقط) | |
| let currentHundred = Math.floor(viewers / 100) * 100; | |
| if (currentHundred >= 100 && currentHundred > highestHundred) { | |
| highestHundred = currentHundred; | |
| const msg = `🎊 <b>إنجاز جديد في البث!</b>\n\n👁️ المشاهدين: <b>${viewers}</b>\n📈 تجاوزنا عتبة: <b>${currentHundred}</b>\n🔗 الرابط: ${liveLink}`; | |
| sendToTelegram(msg); | |
| } | |
| }); | |
| // 3. مراقبة الإعجابات والهدايا 💖🎁 | |
| tiktokConnection.on('like', (data) => { totalLikes = data.totalLikeCount; }); | |
| tiktokConnection.on('gift', (data) => { | |
| totalGifts += data.repeatCount; | |
| // تحديد أكبر داعم بناءً على قيمة الهدايا | |
| if (data.diamondCount > maxGiftCoins) { | |
| maxGiftCoins = data.diamondCount; | |
| topGifterName = data.nickname; | |
| } | |
| }); | |
| // 4. إشعار النهاية (توقيت بغداد 🇮🇶) 🏁 | |
| tiktokConnection.on('disconnected', () => { | |
| const now = new Date(); | |
| const options = { timeZone: 'Asia/Baghdad', year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit', hour12: true }; | |
| const formatter = new Intl.DateTimeFormat('ar-IQ', options); | |
| const parts = formatter.formatToParts(now); | |
| const dateStr = `${parts.find(p => p.type === 'day').value}/${parts.find(p => p.type === 'month').value}/${parts.find(p => p.type === 'year').value}`; | |
| const timeStr = `${parts.find(p => p.type === 'hour').value}:${parts.find(p => p.type === 'minute').value} ${parts.find(p => p.type === 'dayPeriod').value}`; | |
| const endMsg = `🏁 <b>انتهى البث المباشر</b>\n\n` + | |
| `👤 الحساب: <code>${TIKTOK_USERNAME}</code>\n` + | |
| `📅 التاريخ: ${dateStr}\n` + | |
| `⏰ الوقت: ${timeStr}\n` + | |
| `🏆 أعلى مشاهدات: <b>${maxViewers}</b>\n` + | |
| `💖 الإعجابات: <b>${totalLikes}</b>\n` + | |
| `🎁 عدد الهدايا: <b>${totalGifts}</b>\n` + | |
| `🌟 أكبر داعم: <b>${topGifterName}</b>`; | |
| sendToTelegram(endMsg); | |
| setTimeout(() => tiktokConnection.connect(), 30000); | |
| }); | |
| require('http').createServer((req, res) => res.end('Radar Active')).listen(7860); | |