Reooiq commited on
Commit
85a038a
ยท
verified ยท
1 Parent(s): c1251b2

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +138 -308
index.js CHANGED
@@ -1,332 +1,162 @@
1
  const { WebcastPushConnection } = require('tiktok-live-connector');
2
  const axios = require('axios');
3
- const dns = require('dns');
4
- const http = require('http');
5
 
6
  // --- ุฅุนุฏุงุฏุงุช ุงู„ู†ุธุงู… ---
7
- const TELEGRAM_TOKEN = process.env.TELEGRAM_TOKEN;
8
- const TELEGRAM_CHAT_ID = process.env.TELEGRAM_CHAT_ID;
9
- const SESSION_ID = process.env.SESSION_ID;
10
- const FIXED_COUNTRY = "ุงู„ุนุฑุงู‚ ๐Ÿ‡ฎ๐Ÿ‡ถ";
11
- const ACCOUNTS_TO_WATCH = process.env.ACCOUNTS_LIST ? process.env.ACCOUNTS_LIST.split(',') : [];
12
 
13
- dns.setServers(['8.8.8.8']);
14
-
15
- // --- ุฏูˆุงู„ ุงู„ุชู†ุณูŠู‚ ---
16
- function formatK(num) {
17
- if (num >= 1000000) return (num / 1000000).toFixed(1) + 'M';
18
- if (num >= 1000) return (num / 1000).toFixed(1) + 'K';
19
- return num.toString();
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  }
21
 
 
22
  function getBaghdadTime() {
23
- return new Intl.DateTimeFormat('ar-IQ', { timeZone: 'Asia/Baghdad', dateStyle: 'medium', timeStyle: 'medium', hour12: true }).format(new Date());
24
- }
25
-
26
- function formatDuration(totalMinutes) {
27
- if (totalMinutes < 60) return `${totalMinutes} ุฏู‚ูŠู‚ุฉ`;
28
- const hours = Math.floor(totalMinutes / 60);
29
- const minutes = totalMinutes % 60;
30
- return minutes > 0 ? `${hours} ุณุงุนุฉ ูˆ ${minutes} ุฏู‚ูŠู‚ุฉ` : `${hours} ุณุงุนุฉ`;
31
- }
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)));
37
- const baseUrl = `https://${addrs[0]}/bot${TELEGRAM_TOKEN}`;
38
-
39
- let formattedText = targetLink ? `<a href="${targetLink}">โ€โ€โ€Ž โ€Ž</a>` + text : text;
40
- const payload = { chat_id: TELEGRAM_CHAT_ID, parse_mode: 'HTML', disable_web_page_preview: false };
41
-
42
- if (photoUrl) {
43
- payload.photo = photoUrl;
44
- payload.caption = formattedText;
45
- await axios.post(`${baseUrl}/sendPhoto`, payload, { headers: { 'Host': 'api.telegram.org' } });
46
- } else {
47
- payload.text = formattedText;
48
- await axios.post(`${baseUrl}/sendMessage`, payload, { headers: { 'Host': 'api.telegram.org' } });
49
- }
50
-
51
- } catch (e) {
52
- console.log("โš ๏ธ ุฎุทุฃ ุชู„ุฌุฑุงู…");
53
- }
54
  }
55
 
56
- // --- ุงู„ุฑุงุฏุงุฑ ---
57
- async function startRadar(username) {
58
- let user = username.trim();
59
-
60
- const primaryOptions = {
61
- processInitialData: true,
62
- enableWebsocketUpgrade: true,
63
- sessionId: SESSION_ID,
64
- clientParams: {
65
- "app_language": "ar-IQ",
66
- "device_platform": "web",
67
- "tt_target_idc": "useast1a"
68
- }
69
- };
70
-
71
- const fallbackOptions = {
72
- processInitialData: true,
73
- enableWebsocketUpgrade: true,
74
- sessionId: SESSION_ID,
75
- clientParams: {
76
- "app_language": "ar-IQ",
77
- "device_platform": "web"
78
- }
79
- };
80
-
81
- let connection = new WebcastPushConnection(user, primaryOptions);
82
-
83
- let highestHundred = 0, maxViewers = 0, totalLikes = 0, totalShares = 0;
84
- let giftersMap = {}, commentersMap = {};
85
- let adminsSeen = new Set();
86
- let bestGift = { name: "ู„ุง ูŠูˆุฌุฏ", cost: 0, sender: "", icon: "" };
87
- let startTime = null;
88
- let fastCommentCounter = {};
89
- let alertedComments = new Set();
90
-
91
- try {
92
- const state = await connection.connect();
93
- handleConnectionSuccess(state);
94
- } catch (err) {
95
- console.log(`โš ๏ธ ูุดู„ ุงู„ุงุชุตุงู„ ุงู„ุฃุณุงุณูŠ ู„ู€ ${user}ุŒ ู…ุญุงูˆู„ุฉ ุงู„ุงุชุตุงู„ ุงู„ุงุญุชูŠุงุทูŠ...`);
96
- connection = new WebcastPushConnection(user, fallbackOptions);
97
 
 
98
  try {
99
- const state = await connection.connect();
100
- handleConnectionSuccess(state);
101
- } catch (fallbackErr) {
102
- console.log(`โŒ ูุดู„ ุงู„ุงุชุตุงู„ ุงู„ุงุญุชูŠุงุทูŠ ุฃูŠุถุงู‹ ู„ู€ ${user}`);
103
- setTimeout(() => startRadar(user), 60000);
104
- return;
105
- }
106
- }
107
-
108
- // ุนู†ุฏ ู†ุฌุงุญ ๏ฟฝ๏ฟฝู„ุงุชุตุงู„
109
- function handleConnectionSuccess(state) {
110
- startTime = new Date();
111
-
112
- let statusEmoji = state.roomInfo.live_room_mode === 4 ? "๐ŸŽค" : "๐Ÿ”ด";
113
- let statusText = state.roomInfo.live_room_mode === 4 ? "ุชู†ุจูŠู‡: ุตุงุนุฏ ุฌูŠุณุช ุงู„ุขู†!" : "ุงู†ุทู„ุงู‚ ุงู„ุจุซ ุงู„ู…ุจุงุดุฑ";
114
-
115
- let liveLink = `https://www.tiktok.com/@${user}/live`;
116
-
117
- let msg = `${statusEmoji} <b>${statusText}</b>\n` +
118
- `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` +
119
- `๐Ÿ‘ค <b>ุงู„ุญุณุงุจ:</b> <code>${user}</code>\n` +
120
- `๐ŸŒ <b>ุงู„ุฏูˆู„ุฉ:</b> ${FIXED_COUNTRY}\n` +
121
- `๐Ÿ“… <b>ุงู„ูˆู‚ุช:</b> <code>${getBaghdadTime()}</code>\n` +
122
- `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` +
123
- `๐Ÿ”— <b>ุฑุงุจุท ุงู„ุจุซ:</b> <a href="${liveLink}">${liveLink}</a>`;
124
-
125
- sendToTelegram(msg);
126
- }
127
 
128
- // --- ุชุญุฏูŠุซุงุช ู„ุงูŠูƒ ูˆุดุงุฑ ---
129
- connection.on('like', d => totalLikes = d.totalLikeCount);
130
- connection.on('social', d => { if (d.displayType?.includes('share')) totalShares++; });
 
 
 
 
131
 
132
- // --- ุตู†ุงุฏูŠู‚ (ุญู‚ูŠุจุฉ, ูƒูŠุณุช, ุตู†ุฏูˆู‚ ุญุธ) ---
133
- const handleBox = (data, type) => {
134
- let coins =
135
- data.coins ||
136
- data.diamonds ||
137
- data.amount ||
138
- (data.boxInfo && data.boxInfo.rewardDiamond) ||
139
- data.rewardAmount ||
140
- "ุบูŠุฑ ู…ุญุฏุฏ";
141
 
142
- let sender =
143
- data.nickname ||
144
- (data.user && data.user.nickname) ||
145
- "ู…ุฌู‡ูˆู„";
146
-
147
- sendToTelegram(
148
- `๐Ÿ’ฐ <b>ุชู†ุจูŠู‡ ${type}!</b>\n๐Ÿ‘ค ููŠ ุจุซ: @${user}\n๐ŸŽ ู…ู†: <b>${sender}</b>\n๐Ÿ’Ž ุงู„ู‚ูŠู…ุฉ: <b>${coins} ุนู…ู„ุฉ</b>`
149
- );
150
- };
151
-
152
- connection.on('treasureBox', d => handleBox(d, "ุญู‚ูŠุจุฉ ุนู…ู„ุงุช"));
153
- connection.on('luckyBox', d => handleBox(d, "ุตู†ุฏูˆู‚ ุญุธ"));
154
- connection.on('chest', d => handleBox(d, "ูƒูŠุณุช"));
155
- connection.on('chestStart', d => handleBox(d, "ูƒูŠุณุช ุจุฏุฃ"));
156
- connection.on('chestUpdate', d => handleBox(d, "ูƒูŠุณุช ูŠุชุญุฏุซ"));
157
- connection.on('chestEnd', d => handleBox(d, "ูƒูŠุณุช ุงู†ุชู‡ู‰"));
158
-
159
- // --- ุชุนู„ูŠู‚ุงุช + ุณุจุงู… ---
160
- connection.on('chat', (data) => {
161
- let text = data.comment.trim();
162
- let now = Date.now();
163
-
164
- if (!commentersMap[data.userId])
165
- commentersMap[data.userId] = { name: data.nickname, count: 0 };
166
- commentersMap[data.userId].count++;
167
-
168
- if (text.length > 1) {
169
- if (!fastCommentCounter[text]) fastCommentCounter[text] = [];
170
- fastCommentCounter[text].push(now);
171
- fastCommentCounter[text] = fastCommentCounter[text].filter(ts => now - ts < 60000);
172
-
173
- if (fastCommentCounter[text].length >= 100 && !alertedComments.has(text)) {
174
- alertedComments.add(text);
175
- sendToTelegram(`โš ๏ธ <b>ุณุจุงู… ุณุฑูŠุน @${user}!</b>\n๐Ÿ’ฌ "<code>${text}</code>"\n๐Ÿ”ฅ ุชูƒุฑุฑ 100 ู…ุฑุฉ ููŠ ุฏู‚ูŠู‚ุฉ!`);
176
- setTimeout(() => alertedComments.delete(text), 300000);
177
- }
178
  }
179
- });
180
-
181
- // --- ู…ุดุงู‡ุฏูŠู† ---
182
- connection.on('roomUser', d => {
183
- const viewers = d.viewerCount;
184
- if (viewers > maxViewers) maxViewers = viewers;
185
-
186
- let currentHundred = Math.floor(viewers / 100) * 100;
187
 
188
- if (currentHundred >= 100 && currentHundred > highestHundred) {
189
- highestHundred = currentHundred;
190
- sendToTelegram(
191
- `๐Ÿš€ <b>ุฅู†ุฌุงุฒ @${user}:</b> ูˆุตู„ ุงู„ุขู† <code>${formatK(currentHundred)}</code> ู…ุดุงู‡ุฏ!\n๐Ÿ”— <a href="https://www.tiktok.com/@${user}/live">ุฏุฎูˆู„ ุงู„ุจุซ</a>`
192
- );
193
- }
194
- });
195
-
196
- // --- ุฏุฎูˆู„ ุฃุนุถุงุก + VIP + Top Viewer Badge ---
197
- connection.on('member', (data) => {
198
- const level = data.userLevel || (data.user && data.user.userLevel) || 0;
199
-
200
- // ุฏุฎูˆู„ ู…ุดุฑู
201
- if (data.isModerator && !adminsSeen.has(data.uniqueId)) {
202
- adminsSeen.add(data.uniqueId);
203
- sendToTelegram(`๐Ÿ›ก๏ธ <b>ู…ุดุฑู ุฏุฎู„ ุจุซ @${user}:</b>\n๐Ÿ‘ค <code>@${data.uniqueId}</code>`);
204
- }
205
-
206
- // ุฏุฎูˆู„ VIP
207
- if (level >= 30) {
208
- sendToTelegram(`๐Ÿ‘‘ <b>ุฏุฎูˆู„ VIP (Lvl ${level})</b>\n๐Ÿ‘ค ุจุซ @${user}: <code>@${data.uniqueId}</code>`);
209
- }
210
-
211
- // โ€” Top Viewer Badge โ€”
212
- if (data.userBadges && data.userBadges.length > 0) {
213
- let hasTopViewer = data.userBadges.some(b => b.type === "top_viewer");
214
- if (hasTopViewer) {
215
- sendToTelegram(
216
- `๐Ÿ‘‘ <b>Top Viewer ุฏุฎู„ ุงู„ุจุซ!</b>\n` +
217
- `๐Ÿ‘ค ุงู„ู…ุณุชุฎุฏู…: <code>@${data.uniqueId}</code>\n` +
218
- `๐Ÿ“บ ููŠ ุจุซ: @${user}`
219
- );
220
- }
221
- }
222
- });
223
-
224
- // --- ู‡ุฏุงูŠุง ---
225
- connection.on('gift', (data) => {
226
-
227
- if (data.giftType === 1 && !data.repeatEnd) return;
228
-
229
- let giftCost = data.diamondCount * data.repeatCount;
230
-
231
- if (!giftersMap[data.userId])
232
- giftersMap[data.userId] = { name: data.nickname, coins: 0 };
233
- giftersMap[data.userId].coins += giftCost;
234
-
235
- if (giftCost > bestGift.cost)
236
- bestGift = { name: data.giftName, cost: giftCost, sender: data.nickname, icon: data.giftPictureUrl };
237
-
238
- // --- ู…ูŠุฒุฉ 7: ุฅุฑุณุงู„ ุตูˆุฑุฉ ุงู„ู‡ุฏูŠุฉ ---
239
- if (data.giftPictureUrl) {
240
- sendToTelegram(
241
- `๐ŸŽ <b>ู‡ุฏูŠุฉ ุฌุฏูŠุฏุฉ!</b>\n` +
242
- `๐Ÿ‘ค ู…ู†: <b>${data.nickname}</b>\n` +
243
- `๐ŸŽ ุงู„ู‡ุฏูŠุฉ: <b>${data.giftName}</b>\n` +
244
- `๐Ÿ’Ž ุงู„ู‚ูŠู…ุฉ: <b>${giftCost}</b>`,
245
- data.giftPictureUrl
246
- );
247
- }
248
-
249
- // --- ู…ูŠุฒุฉ 9: ู‡ุฏูŠุฉ ูู„ุงุด ---
250
- if (data.repeatCount > 1 && data.repeatEnd === true) {
251
- sendToTelegram(
252
- `โšก <b>ู‡ุฏูŠุฉ ูู„ุงุด ู…ูƒุชู…ู„ุฉ!</b>\n` +
253
- `๐ŸŽ ${data.giftName}\n` +
254
- `๐Ÿ”ฅ ุงู„ุนุฏุฏ: ${data.repeatCount}\n` +
255
- `๐Ÿ‘ค ู…ู†: <b>${data.nickname}</b>`
256
- );
257
- }
258
-
259
- });
260
-
261
- // --- ุชุซุจูŠุช ุชุนู„ูŠู‚ ---
262
- connection.on('livePinnedMessage', (data) => {
263
- let sender = data.user?.uniqueId || "ุงู„ู…ุถูŠู";
264
- let text = data.content || data.text || "ุชุนู„ูŠู‚ ุบูŠุฑ ู…ุนุฑูˆู";
265
-
266
- sendToTelegram(
267
- `๐Ÿ“Œ <b>ุชู… ุชุซุจูŠุช ุชุนู„ูŠู‚ ููŠ ุจุซ @${user}</b>\n` +
268
- `๐Ÿ‘ค ุจูˆุงุณุทุฉ: <code>@${sender}</code>\n` +
269
- `๐Ÿ’ฌ <b>${text}</b>`
270
- );
271
- });
272
-
273
- connection.on('roomPinMessage', (data) => {
274
- let sender = data.user?.uniqueId || "ุงู„ู…ุถูŠู";
275
- let text = data.content || data.text || "ุชุนู„ูŠู‚ ุบูŠุฑ ู…ุนุฑูˆู";
276
-
277
- sendToTelegram(
278
- `๐Ÿ“Œ <b>ุชู… ุชุซุจูŠุช ุชุนู„ูŠู‚ ููŠ ุจุซ @${user}</b>\n` +
279
- `๐Ÿ‘ค ุจูˆุงุณุทุฉ: <code>@${sender}</code>\n` +
280
- `๐Ÿ’ฌ <b>${text}</b>`
281
- );
282
- });
283
-
284
- // --- ู†ู‡ุงูŠุฉ ุงู„ุจุซ ---
285
- connection.on('disconnected', () => {
286
- const diffMs = new Date() - startTime;
287
- const totalMinutes = startTime ? Math.floor(diffMs / 60000) : 0;
288
- const durationStr = formatDuration(totalMinutes);
289
-
290
- let sortedGifters = Object.values(giftersMap).sort((a, b) => b.coins - a.coins).slice(0, 3);
291
- let sortedCommenters = Object.values(commentersMap).sort((a, b) => b.count - a.count).slice(0, 5);
292
-
293
- let endMsg =
294
- `๐Ÿ <b>ู…ู„ุฎุต ุงู„ู†ู‡ุงูŠุฉ (@${user})</b>\n` +
295
- `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` +
296
- `โฑ๏ธ <b>ุงู„ู…ุฏุฉ:</b> ${durationStr} | ๐Ÿ“… <b>ุงู„ูˆู‚ุช:</b> ${getBaghdadTime()}\n` +
297
- `๐Ÿ“Š ๐Ÿ‘๏ธ ${formatK(maxViewers)} | โค๏ธ ${formatK(totalLikes)} | ๐Ÿ”„ ${totalShares}\n` +
298
- `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` +
299
- `๐Ÿ† <b>ุฃูุถู„ 3 ุฏุงุนู…ูŠู†:</b>\n`;
300
-
301
- sortedGifters.forEach((g, i) => {
302
- endMsg += `${i === 0 ? '๐Ÿฅ‡' : i === 1 ? '๐Ÿฅˆ' : '๐Ÿฅ‰'} <code>${g.name}</code> : <b>${formatK(g.coins)}</b>\n`;
303
  });
304
 
305
- endMsg += `\n๐Ÿ’ฌ <b>ุฃูƒุซุฑ 5 ู…ุนู„ู‚ูŠู† ุชูุงุนู„ุงู‹:</b>\n`;
306
- sortedCommenters.forEach((c, i) => {
307
- endMsg += `${i + 1}. <code>${c.name}</code> (${c.count})\n`;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  });
309
 
310
- if (bestGift.cost > 0)
311
- endMsg += `\n๐Ÿ’Ž <b>ุฃู‚ูˆู‰ ู‡ุฏูŠุฉ:</b> ${bestGift.name} ู…ู† <b>${bestGift.sender}</b>`;
312
-
313
- sendToTelegram(endMsg, bestGift.icon || null, `https://www.tiktok.com/@${user}/live`);
314
-
315
- fastCommentCounter = {};
316
- alertedComments = new Set();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
 
318
- setTimeout(() => startRadar(user), 30000);
319
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  }
321
 
322
- // --- ุชุดุบูŠู„ ุงู„ุฑุงุฏุงุฑ ---
323
- if (ACCOUNTS_TO_WATCH.length > 0)
324
- ACCOUNTS_TO_WATCH.forEach(user => startRadar(user));
325
-
326
- // --- ุงู„ุณูŠุฑูุฑ ---
327
- const server = http.createServer((req, res) => res.end('Radar Mega V7.1 Active ๐Ÿš€'));
328
- server.listen(7860, '0.0.0.0', () => {
329
- setInterval(() => {
330
- http.get(`http://localhost:7860`, () => {}).on('error', () => {});
331
- }, 240000);
332
- });
 
1
  const { WebcastPushConnection } = require('tiktok-live-connector');
2
  const axios = require('axios');
 
 
3
 
4
  // --- ุฅุนุฏุงุฏุงุช ุงู„ู†ุธุงู… ---
5
+ const TIKTOK_USERNAME = "USERNAME_HERE"; // ุถุน ุงุณู… ุตุงุญุจ ุงู„ุจุซ
6
+ const TELEGRAM_BOT_TOKEN = "YOUR_TELEGRAM_TOKEN";
7
+ const TELEGRAM_CHAT_ID = "YOUR_CHAT_ID";
 
 
8
 
9
+ // --- ุฏุงู„ุฉ ุฅุฑุณุงู„ ุฑุณุงุฆู„ ุชู„ุฌุฑุงู… ู…ุน ุชู†ุณูŠู‚ ุงุญุชุฑุงููŠ ---
10
+ async function sendToTelegram(message, imageUrl = null) {
11
+ try {
12
+ if (imageUrl) {
13
+ await axios.post(`https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendPhoto`, {
14
+ chat_id: TELEGRAM_CHAT_ID,
15
+ photo: imageUrl,
16
+ caption: message,
17
+ parse_mode: "HTML"
18
+ });
19
+ } else {
20
+ await axios.post(`https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage`, {
21
+ chat_id: TELEGRAM_CHAT_ID,
22
+ text: message,
23
+ parse_mode: "HTML"
24
+ });
25
+ }
26
+ } catch (err) {
27
+ console.log("Telegram Error:", err.message);
28
+ }
29
  }
30
 
31
+ // --- ุฏุงู„ุฉ ุชู†ุณูŠู‚ ุงู„ูˆู‚ุช ุจุดูƒู„ ุงุญุชุฑุงููŠ ---
32
  function getBaghdadTime() {
33
+ return new Intl.DateTimeFormat('ar-IQ', { timeZone: 'Asia/Baghdad', dateStyle: 'medium', timeStyle: 'medium', hour12: true }).format(new Date());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
+ // --- ุจุฏุก ุงู„ุฑุงุฏุงุฑ ---
37
+ async function startRadar() {
38
+ const connection = new WebcastPushConnection(TIKTOK_USERNAME);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
+ // --- ุฌู„ุจ ุงู„ุฏูˆู„ุฉ ู‚ุจู„ ุงู„ุจุซ ---
41
  try {
42
+ const info = await connection.getRoomInfo();
43
+ const country = info?.owner?.region || info?.owner?.country || "ุบูŠุฑ ู…ุนุฑูˆู";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
+ const startMsg =
46
+ `๐ŸŸข <b>ุชู… ุจุฏุก ุงู„ุฑุงุฏุงุฑ ู„ู„ุจุซ</b>\n` +
47
+ `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` +
48
+ `๐Ÿ‘ค ุงู„ุญุณุงุจ: @${TIKTOK_USERNAME}\n` +
49
+ `๐ŸŒ ุงู„ุฏูˆู„ุฉ: <b>${country}</b>\n` +
50
+ `โฐ ุงู„ูˆู‚ุช: ${getBaghdadTime()}\n` +
51
+ `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€`;
52
 
53
+ await sendToTelegram(startMsg);
 
 
 
 
 
 
 
 
54
 
55
+ } catch (e) {
56
+ console.log("ู„ุง ูŠู…ูƒู† ุฌู„ุจ ุงู„ุฏูˆู„ุฉ ุงู„ุขู†");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
 
 
 
 
 
 
 
 
58
 
59
+ // --- ุนู†ุฏ ุงู„ุงุชุตุงู„ ุจุงู„ุจุซ ---
60
+ connection.connect().then(state => {
61
+ const liveMsg =
62
+ `๐Ÿ”ด <b>ุงู„ุจุซ ุงู„ู…ุจุงุดุฑ ุจุฏุฃ ุงู„ุขู†!</b>\n` +
63
+ `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` +
64
+ `๐Ÿ‘ค ุงู„ุญุณุงุจ: @${TIKTOK_USERNAME}\n` +
65
+ `๐ŸŒ ุงู„ุฏูˆู„ุฉ: <b>${state.roomInfo.owner?.region || state.roomInfo.owner?.country || "ุบูŠุฑ ู…ุนุฑูˆู"}</b>\n` +
66
+ `โฐ ุงู„ูˆู‚ุช: ${getBaghdadTime()}\n` +
67
+ `๐Ÿ”— <a href="https://www.tiktok.com/@${TIKTOK_USERNAME}/live">ุฑุงุจุท ุงู„ุจุซ ุงู„ู…ุจุงุดุฑ</a>\n` +
68
+ `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€`;
69
+
70
+ sendToTelegram(liveMsg);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  });
72
 
73
+ // --- ุฏุฎูˆู„ ู…ุดุงู‡ุฏ / VIP / Top Viewer ---
74
+ connection.on('member', data => {
75
+ const level = data.userLevel || (data.user && data.user.userLevel) || 0;
76
+
77
+ let memberMsg = '';
78
+ if (data.isModerator) {
79
+ memberMsg += `๐Ÿ›ก๏ธ <b>ู…ุดุฑู ุฏุฎู„ ุงู„ุจุซ</b>\n`;
80
+ }
81
+ if (level >= 30) {
82
+ memberMsg += `๐Ÿ‘‘ <b>VIP (Lvl ${level}) ุฏุฎู„ ุงู„ุจุซ</b>\n`;
83
+ }
84
+
85
+ if (data.userBadges && data.userBadges.length > 0) {
86
+ const hasTopViewer = data.userBadges.some(b => b.type === "top_viewer");
87
+ if (hasTopViewer) {
88
+ memberMsg += `๐Ÿ… <b>Top Viewer ุฏุฎู„ ุงู„ุจุซ!</b>\n`;
89
+ }
90
+ }
91
+
92
+ if (memberMsg) {
93
+ memberMsg += `๐Ÿ‘ค ุงู„ู…ุณุชุฎุฏู…: <code>@${data.uniqueId}</code>\n` +
94
+ `โฐ ุงู„ูˆู‚ุช: ${getBaghdadTime()}\n` +
95
+ `โ”€โ”€โ”€๏ฟฝ๏ฟฝ๏ฟฝโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€`;
96
+ sendToTelegram(memberMsg);
97
+ }
98
  });
99
 
100
+ // --- ุงู„ู‡ุฏุงูŠุง ---
101
+ connection.on('gift', data => {
102
+ let giftCost = data.diamondCount * data.repeatCount;
103
+
104
+ // ุฑุณุงู„ุฉ ุงุญุชุฑุงููŠุฉ ู„ู„ู‡ุฏูŠุฉ
105
+ const giftMsg =
106
+ `๐ŸŽ <b>ู‡ุฏูŠุฉ ุฌุฏูŠุฏุฉ!</b>\n` +
107
+ `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n` +
108
+ `๐Ÿ‘ค ู…ู†: <b>${data.nickname}</b>\n` +
109
+ `๐ŸŽ ุงุณู… ุงู„ู‡ุฏูŠุฉ: <b>${data.giftName}</b>\n` +
110
+ `๐Ÿ’Ž ุงู„ู‚ูŠู…ุฉ: <b>${giftCost}</b>\n` +
111
+ `โฐ ุงู„ูˆู‚ุช: ${getBaghdadTime()}\n` +
112
+ `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€`;
113
+
114
+ if (data.giftPictureUrl) {
115
+ sendToTelegram(giftMsg, data.giftPictureUrl);
116
+ } else {
117
+ sendToTelegram(giftMsg);
118
+ }
119
+
120
+ // ู‡ุฏูŠุฉ ูู„ุงุด
121
+ if (data.repeatCount > 1 && data.repeatEnd === true) {
122
+ const streakMsg =
123
+ `โšก <b>ู‡ุฏูŠุฉ ูู„ุงุด ู…ูƒุชู…ู„ุฉ!</b>\n` +
124
+ `๐Ÿ‘ค ู…ู†: <b>${data.nickname}</b>\n` +
125
+ `๐ŸŽ ${data.giftName}\n` +
126
+ `๐Ÿ”ฅ ุงู„ุนุฏุฏ: ${data.repeatCount}\n` +
127
+ `โฐ ุงู„ูˆู‚ุช: ${getBaghdadTime()}\n` +
128
+ `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€`;
129
+ sendToTelegram(streakMsg);
130
+ }
131
+ });
132
 
133
+ // --- ุชุซุจูŠุช ุชุนู„ูŠู‚ ---
134
+ const pinnedHandler = (data) => {
135
+ const sender = data.user?.uniqueId || "ุงู„ู…ุถูŠู";
136
+ const text = data.content || data.text || "ุชุนู„ูŠู‚ ุบูŠุฑ ู…ุนุฑูˆู";
137
+
138
+ const pinnedMsg =
139
+ `๐Ÿ“Œ <b>ุชุนู„ูŠู‚ ู…ุซุจุช</b>\n` +
140
+ `๐Ÿ‘ค ุจูˆุงุณุทุฉ: <code>@${sender}</code>\n` +
141
+ `๐Ÿ’ฌ ${text}\n` +
142
+ `โฐ ุงู„ูˆู‚ุช: ${getBaghdadTime()}\n` +
143
+ `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€`;
144
+
145
+ sendToTelegram(pinnedMsg);
146
+ };
147
+
148
+ connection.on('livePinnedMessage', pinnedHandler);
149
+ connection.on('roomPinMessage', pinnedHandler);
150
+
151
+ // --- ุงู†ุชู‡ุงุก ุงู„ุจุซ ---
152
+ connection.on('streamEnd', () => {
153
+ const endMsg =
154
+ `๐Ÿ”ด <b>ุงู†ุชู‡ู‰ ุงู„ุจุซ</b>\n` +
155
+ `๐Ÿ‘ค @${TIKTOK_USERNAME}\n` +
156
+ `โฐ ุงู„ูˆู‚ุช: ${getBaghdadTime()}\n` +
157
+ `โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€`;
158
+ sendToTelegram(endMsg);
159
+ });
160
  }
161
 
162
+ startRadar();