Update index.js
Browse files
index.js
CHANGED
|
@@ -2,16 +2,17 @@ const WebSocket = require('ws');
|
|
| 2 |
const axios = require('axios');
|
| 3 |
const http = require('http');
|
| 4 |
|
| 5 |
-
// ---
|
| 6 |
const EULER_API_KEY = "Euler_Y2FlYTIyODYzNDQ0OTcxZjYyNGExZTkyMDM2NTMwZWE1ZjUzYmZmMDVmMGNlYjg0YzkzY2Vk";
|
| 7 |
const TELEGRAM_TOKEN = "8576498050:AAHB51H9vLwFhDUFqYWttPaSa5qhPLzQVWE";
|
| 8 |
const TELEGRAM_CHAT_ID = "-1002856018359";
|
| 9 |
const TIKTOK_USERNAME = "ah_md107";
|
|
|
|
| 10 |
|
| 11 |
-
//
|
| 12 |
http.createServer((req, res) => {
|
| 13 |
res.writeHead(200);
|
| 14 |
-
res.end('
|
| 15 |
}).listen(7860);
|
| 16 |
|
| 17 |
async function sendToTelegram(text) {
|
|
@@ -20,54 +21,52 @@ async function sendToTelegram(text) {
|
|
| 20 |
chat_id: TELEGRAM_CHAT_ID,
|
| 21 |
text: text,
|
| 22 |
parse_mode: 'HTML'
|
| 23 |
-
});
|
| 24 |
-
} catch (e) {
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
function connect() {
|
| 28 |
-
//
|
| 29 |
-
const wsUrl = `wss://ws.eulerstream.com/v1/webcast?uniqueId=${TIKTOK_USERNAME}`;
|
| 30 |
|
| 31 |
-
const ws = new WebSocket(wsUrl
|
| 32 |
-
headers: {
|
| 33 |
-
"Authorization": `Bearer ${EULER_API_KEY}`,
|
| 34 |
-
"Content-Type": "application/json"
|
| 35 |
-
}
|
| 36 |
-
});
|
| 37 |
|
| 38 |
ws.on('open', () => {
|
| 39 |
console.log("✅ تم الربط بنجاح مع EulerStream");
|
| 40 |
-
sendToTelegram(`📡 <b>تم ال
|
| 41 |
});
|
| 42 |
|
| 43 |
ws.on('message', (data) => {
|
| 44 |
try {
|
| 45 |
const event = JSON.parse(data);
|
| 46 |
|
| 47 |
-
//
|
| 48 |
-
if (event.type === 'comment'
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
sendToTelegram(`
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
// التعامل مع الهدايا
|
| 55 |
-
if (event.type === 'gift') {
|
| 56 |
-
sendToTelegram(`🎁 <b>${event.nickname}</b> أرسل هدية: ${event.giftName}`);
|
| 57 |
}
|
| 58 |
-
} catch (e) {
|
|
|
|
|
|
|
| 59 |
});
|
| 60 |
|
| 61 |
ws.on('close', (code) => {
|
| 62 |
-
console.log(`❌ انقطع، الكود: ${code}`);
|
| 63 |
|
| 64 |
-
|
| 65 |
-
if (code ===
|
| 66 |
-
console.log("⚠️
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
}
|
|
|
|
|
|
|
| 71 |
});
|
| 72 |
|
| 73 |
ws.on('error', (err) => {
|
|
|
|
| 2 |
const axios = require('axios');
|
| 3 |
const http = require('http');
|
| 4 |
|
| 5 |
+
// --- بياناتك الشخصية المستخرجة من الصور ---
|
| 6 |
const EULER_API_KEY = "Euler_Y2FlYTIyODYzNDQ0OTcxZjYyNGExZTkyMDM2NTMwZWE1ZjUzYmZmMDVmMGNlYjg0YzkzY2Vk";
|
| 7 |
const TELEGRAM_TOKEN = "8576498050:AAHB51H9vLwFhDUFqYWttPaSa5qhPLzQVWE";
|
| 8 |
const TELEGRAM_CHAT_ID = "-1002856018359";
|
| 9 |
const TIKTOK_USERNAME = "ah_md107";
|
| 10 |
+
const ACCOUNT_ID = "7158"; // معرف حسابك الظاهر في الصورة الأولى
|
| 11 |
|
| 12 |
+
// خادم وهمي لضمان استقرار الاستضافة على Hugging Face
|
| 13 |
http.createServer((req, res) => {
|
| 14 |
res.writeHead(200);
|
| 15 |
+
res.end('Bot Monitoring: ah_md107');
|
| 16 |
}).listen(7860);
|
| 17 |
|
| 18 |
async function sendToTelegram(text) {
|
|
|
|
| 21 |
chat_id: TELEGRAM_CHAT_ID,
|
| 22 |
text: text,
|
| 23 |
parse_mode: 'HTML'
|
| 24 |
+
}, { timeout: 10000 });
|
| 25 |
+
} catch (e) {
|
| 26 |
+
console.log("⚠️ Telegram Error: Connection Timeout");
|
| 27 |
+
}
|
| 28 |
}
|
| 29 |
|
| 30 |
function connect() {
|
| 31 |
+
// الرابط الرسمي المباشر وفقاً لأحدث تحديثات الموقع
|
| 32 |
+
const wsUrl = `wss://ws.eulerstream.com/v1/webcast?uniqueId=${TIKTOK_USERNAME}&apiKey=${EULER_API_KEY}&accountId=${ACCOUNT_ID}`;
|
| 33 |
|
| 34 |
+
const ws = new WebSocket(wsUrl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
ws.on('open', () => {
|
| 37 |
console.log("✅ تم الربط بنجاح مع EulerStream");
|
| 38 |
+
sendToTelegram(`📡 <b>تم بدء المراقبة بنجاح!</b>\nالحساب: <code>${TIKTOK_USERNAME}</code>`);
|
| 39 |
});
|
| 40 |
|
| 41 |
ws.on('message', (data) => {
|
| 42 |
try {
|
| 43 |
const event = JSON.parse(data);
|
| 44 |
|
| 45 |
+
// معالجة بيانات البث
|
| 46 |
+
if (event.type === 'comment') {
|
| 47 |
+
sendToTelegram(`💬 <b>${event.nickname}:</b> ${event.comment}`);
|
| 48 |
+
} else if (event.type === 'gift') {
|
| 49 |
+
sendToTelegram(`🎁 <b>${event.nickname}</b> أرسل: ${event.giftName} (x${event.repeatCount})`);
|
| 50 |
+
} else if (event.type === 'social') {
|
| 51 |
+
sendToTelegram(`👤 <b>${event.nickname}</b> قام بمتابعة الحساب!`);
|
|
|
|
|
|
|
|
|
|
| 52 |
}
|
| 53 |
+
} catch (e) {
|
| 54 |
+
// تجاهل البيانات غير النصية
|
| 55 |
+
}
|
| 56 |
});
|
| 57 |
|
| 58 |
ws.on('close', (code) => {
|
| 59 |
+
console.log(`❌ انقطع الاتصال، الكود: ${code}`);
|
| 60 |
|
| 61 |
+
let delay = 5000;
|
| 62 |
+
if (code === 4400) {
|
| 63 |
+
console.log("⚠️ مشكلة في صياغة الطلب، جاري المحاولة برابط بديل...");
|
| 64 |
+
} else if (code === 4556) {
|
| 65 |
+
console.log("ℹ️ بانتظار استقرار بيانات البث من تيك توك...");
|
| 66 |
+
delay = 15000;
|
| 67 |
}
|
| 68 |
+
|
| 69 |
+
setTimeout(connect, delay);
|
| 70 |
});
|
| 71 |
|
| 72 |
ws.on('error', (err) => {
|