Update index.js
Browse files
index.js
CHANGED
|
@@ -23,6 +23,14 @@ function getBaghdadTime() {
|
|
| 23 |
return new Intl.DateTimeFormat('ar-IQ', { timeZone: 'Asia/Baghdad', dateStyle: 'medium', timeStyle: 'medium', hour12: true }).format(new Date());
|
| 24 |
}
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
async function sendToTelegram(text, photoUrl = null, targetLink = null) {
|
| 27 |
try {
|
| 28 |
const addrs = await new Promise(r => dns.resolve4('api.telegram.org', (e, a) => r(a)));
|
|
@@ -84,11 +92,9 @@ async function startRadar(username) {
|
|
| 84 |
sendToTelegram(msg);
|
| 85 |
}
|
| 86 |
|
| 87 |
-
// --- ุชุญุฏูุซ ุงูุฅุนุฌุงุจุงุช ูุงูุดูุฑุงุช ---
|
| 88 |
connection.on('like', (data) => { totalLikes = data.totalLikeCount; });
|
| 89 |
connection.on('social', (data) => { if (data.displayType && data.displayType.includes('share')) totalShares++; });
|
| 90 |
|
| 91 |
-
// --- ู
ุนุงูุฌุฉ ุงูุตูุงุฏูู ูุงูุญูุงุฆุจ ---
|
| 92 |
const handleBox = (data, type) => {
|
| 93 |
let coins = data.coins || data.diamonds || data.amount || "ุบูุฑ ู
ุญุฏุฏ";
|
| 94 |
let sender = data.nickname || (data.user && data.user.nickname) || 'ู
ุฌููู';
|
|
@@ -97,7 +103,7 @@ async function startRadar(username) {
|
|
| 97 |
|
| 98 |
connection.on('treasureBox', (data) => handleBox(data, "ุญููุจุฉ ุนู
ูุงุช"));
|
| 99 |
connection.on('luckyBox', (data) => handleBox(data, "ุตูุฏูู ุญุธ"));
|
| 100 |
-
connection.on('chest', (data) => handleBox(data, "ุญููุจุฉ (ุชูุงุนู)"));
|
| 101 |
connection.on('envelope', (data) => handleBox(data, "ู
ุบูู ุนู
ูุงุช"));
|
| 102 |
|
| 103 |
connection.on('chat', (data) => {
|
|
@@ -133,7 +139,8 @@ async function startRadar(username) {
|
|
| 133 |
adminsSeen.add(data.uniqueId);
|
| 134 |
sendToTelegram(`๐ก๏ธ <b>ู
ุดุฑู ุฏุฎู ุจุซ @${user}:</b>\n๐ค <code>@${data.uniqueId}</code>`);
|
| 135 |
}
|
| 136 |
-
|
|
|
|
| 137 |
});
|
| 138 |
|
| 139 |
connection.on('gift', (data) => {
|
|
@@ -145,7 +152,11 @@ async function startRadar(username) {
|
|
| 145 |
});
|
| 146 |
|
| 147 |
connection.on('disconnected', () => {
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
let sortedGifters = Object.values(giftersMap).sort((a, b) => b.coins - a.coins).slice(0, 3);
|
| 150 |
let sortedCommenters = Object.values(commentersMap).sort((a, b) => b.count - a.count).slice(0, 5);
|
| 151 |
let endMsg = `๐ <b>ู
ูุฎุต ุงูููุงูุฉ (@${user})</b>\nโโโโโโโโโโโโโโโโโ\nโฑ๏ธ <b>ุงูู
ุฏุฉ:</b> ${durationStr} | ๐
<b>ุงูููุช:</b> ${getBaghdadTime()}\n๐ ๐๏ธ ${formatK(maxViewers)} | โค๏ธ ${formatK(totalLikes)} | ๐ ${totalShares}\nโโโโโโโโโโโโโโโโโ\n๐ <b>ุฃูุถู 3 ุฏุงุนู
ูู:</b>\n`;
|
|
|
|
| 23 |
return new Intl.DateTimeFormat('ar-IQ', { timeZone: 'Asia/Baghdad', dateStyle: 'medium', timeStyle: 'medium', hour12: true }).format(new Date());
|
| 24 |
}
|
| 25 |
|
| 26 |
+
// ุฏุงูุฉ ุชุญููู ุงูุฏูุงุฆู ุฅูู ุณุงุนุงุช ูุฏูุงุฆู
|
| 27 |
+
function formatDuration(totalMinutes) {
|
| 28 |
+
if (totalMinutes < 60) return `${totalMinutes} ุฏูููุฉ`;
|
| 29 |
+
const hours = Math.floor(totalMinutes / 60);
|
| 30 |
+
const minutes = totalMinutes % 60;
|
| 31 |
+
return minutes > 0 ? `${hours} ุณุงุนุฉ ู ${minutes} ุฏูููุฉ` : `${hours} ุณุงุนุฉ`;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
async function sendToTelegram(text, photoUrl = null, targetLink = null) {
|
| 35 |
try {
|
| 36 |
const addrs = await new Promise(r => dns.resolve4('api.telegram.org', (e, a) => r(a)));
|
|
|
|
| 92 |
sendToTelegram(msg);
|
| 93 |
}
|
| 94 |
|
|
|
|
| 95 |
connection.on('like', (data) => { totalLikes = data.totalLikeCount; });
|
| 96 |
connection.on('social', (data) => { if (data.displayType && data.displayType.includes('share')) totalShares++; });
|
| 97 |
|
|
|
|
| 98 |
const handleBox = (data, type) => {
|
| 99 |
let coins = data.coins || data.diamonds || data.amount || "ุบูุฑ ู
ุญุฏุฏ";
|
| 100 |
let sender = data.nickname || (data.user && data.user.nickname) || 'ู
ุฌููู';
|
|
|
|
| 103 |
|
| 104 |
connection.on('treasureBox', (data) => handleBox(data, "ุญููุจุฉ ุนู
ูุงุช"));
|
| 105 |
connection.on('luckyBox', (data) => handleBox(data, "ุตูุฏูู ุญุธ"));
|
| 106 |
+
connection.on('chest', (data) => handleBox(data, "ุญููุจุฉ (ุชูุงุนู)"));
|
| 107 |
connection.on('envelope', (data) => handleBox(data, "ู
ุบูู ุนู
ูุงุช"));
|
| 108 |
|
| 109 |
connection.on('chat', (data) => {
|
|
|
|
| 139 |
adminsSeen.add(data.uniqueId);
|
| 140 |
sendToTelegram(`๐ก๏ธ <b>ู
ุดุฑู ุฏุฎู ุจุซ @${user}:</b>\n๐ค <code>@${data.uniqueId}</code>`);
|
| 141 |
}
|
| 142 |
+
// ุงูุชุนุฏูู: ุชุฑุญูุจ VIP ู
ู ููู 30 ูููู
|
| 143 |
+
if (data.userLevel >= 30) sendToTelegram(`๐ <b>ุฏุฎูู VIP (Lvl ${data.userLevel})</b>\n๐ค ุจุซ @${user}: <code>@${data.uniqueId}</code>`);
|
| 144 |
});
|
| 145 |
|
| 146 |
connection.on('gift', (data) => {
|
|
|
|
| 152 |
});
|
| 153 |
|
| 154 |
connection.on('disconnected', () => {
|
| 155 |
+
// ุงูุชุนุฏูู: ุญุณุงุจ ุงูู
ุฏู ูุชุญููููุง ูุณุงุนุงุช ุฅุฐุง ุชุฌุงูุฒุช 60 ุฏูููุฉ
|
| 156 |
+
const diffMs = new Date() - startTime;
|
| 157 |
+
const totalMinutes = startTime ? Math.floor(diffMs / 60000) : 0;
|
| 158 |
+
const durationStr = startTime ? formatDuration(totalMinutes) : "ุบูุฑ ู
ุญุฏุฏ";
|
| 159 |
+
|
| 160 |
let sortedGifters = Object.values(giftersMap).sort((a, b) => b.coins - a.coins).slice(0, 3);
|
| 161 |
let sortedCommenters = Object.values(commentersMap).sort((a, b) => b.count - a.count).slice(0, 5);
|
| 162 |
let endMsg = `๐ <b>ู
ูุฎุต ุงูููุงูุฉ (@${user})</b>\nโโโโโโโโโโโโโโโโโ\nโฑ๏ธ <b>ุงูู
ุฏุฉ:</b> ${durationStr} | ๐
<b>ุงูููุช:</b> ${getBaghdadTime()}\n๐ ๐๏ธ ${formatK(maxViewers)} | โค๏ธ ${formatK(totalLikes)} | ๐ ${totalShares}\nโโโโโโโโโโโโโโโโโ\n๐ <b>ุฃูุถู 3 ุฏุงุนู
ูู:</b>\n`;
|