File size: 20,460 Bytes
03a92a9
3f354c6
03a92a9
925da1c
03a92a9
901ed02
03a92a9
3b24101
 
32d6468
3f354c6
d85e9c2
 
 
056939b
d85e9c2
 
 
 
 
 
 
 
 
 
 
 
 
711dfc6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ff308cf
35c7074
 
 
 
ff308cf
35c7074
 
 
 
 
 
 
 
 
 
 
d22a349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d89445c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
711dfc6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d89445c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d22a349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35c7074
 
fc4319b
35c7074
 
 
 
 
fc8b3f7
35c7074
fc4319b
35c7074
 
 
 
 
 
 
 
 
 
fc4319b
35c7074
fc4319b
 
f87cf87
fc4319b
35c7074
fc4319b
901ed02
 
 
 
 
 
 
35c7074
901ed02
 
 
 
 
 
 
fc4319b
 
babfe15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00760c8
babfe15
 
 
 
 
 
 
 
35c7074
 
00760c8
fc8b3f7
 
fc4319b
fc8b3f7
fc4319b
fc8b3f7
 
fc4319b
 
fc8b3f7
fc4319b
fc8b3f7
 
 
 
 
 
 
 
 
 
fc4319b
fc8b3f7
 
 
901ed02
 
fc4319b
901ed02
 
 
fc4319b
901ed02
 
35c7074
d85e9c2
 
 
 
 
 
 
 
 
 
 
 
e57de41
d85e9c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8788832
 
 
 
 
90fae10
8788832
 
 
 
 
 
caa8423
8788832
 
 
 
 
 
 
 
 
 
a9746de
a379ce0
 
 
 
 
 
 
 
 
4b02fd3
76554b4
 
4b02fd3
76554b4
 
 
 
 
 
 
 
 
 
 
4b02fd3
76554b4
 
 
 
 
 
caa8423
 
 
90fae10
caa8423
90fae10
caa8423
 
 
 
 
 
 
90fae10
caa8423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d9d9e44
03a92a9
 
d9d9e44
03a92a9
d9d9e44
03a92a9
d9d9e44
03a92a9
 
d9d9e44
 
 
03a92a9
 
 
 
d9d9e44
 
 
 
 
724afa1
86aa7e7
d584fea
 
 
 
 
724afa1
 
bbec6d3
 
 
 
 
 
 
724afa1
 
bbec6d3
 
 
 
 
 
724afa1
 
d584fea
 
 
 
 
86aa7e7
d584fea
39000f4
 
 
03a92a9
d9d9e44
39000f4
 
 
 
 
 
 
 
 
2b87901
 
 
 
90fae10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33f3e99
2b87901
 
 
0d15ce1
2b87901
 
 
0d15ce1
2b87901
0d15ce1
2b87901
 
 
0d15ce1
 
 
2b87901
 
 
0d15ce1
2b87901
0d15ce1
2b87901
 
 
0d15ce1
2b87901
 
0d15ce1
 
2b87901
 
 
90fae10
 
 
 
 
 
 
0d15ce1
 
 
 
 
 
 
2b87901
 
 
0d15ce1
 
 
 
 
 
 
 
 
2b87901
 
0d15ce1
2b87901
 
 
33f3e99
 
 
 
90fae10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33f3e99
 
 
 
 
 
 
 
 
 
 
 
1565850
33f3e99
 
 
 
 
 
 
 
39000f4
 
 
 
90fae10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39000f4
 
 
 
 
 
 
d9d9e44
39000f4
 
03a92a9
d9d9e44
39000f4
 
 
 
 
 
 
d9d9e44
03a92a9
d9d9e44
03a92a9
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
import express from 'express';
import axios from 'axios';
import { Database } from '../database/database.js';
import { predictCreationDate } from '../lib/create-date.js';
import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
import { Job } from '../models.js';
const AntibanRoutes = express.Router();
import * as uuid from 'uuid';

const protectedUsers = [6477856957, 1191668125, 1448273246, 1054295664, 6444305696]; 

const TelegramUser = async (user_id) => {
  const options = {
    method: 'GET',
    url: 'https://randydev-meta-ai.hf.space/user/get_user',
    params: {
      user_id: user_id
    }
  };
  try {
    const response = await axios.request(options);
    return response.data;
  } catch (error) {
    console.error(error);
    return null;
  }
}

const TelegramUserStatusBan = async (user_id) => {
  const options = {
    method: 'GET',
    url: 'https://randydev-meta-ai.hf.space/user/status/ban',
    params: {
      username: user_id
    }
  };
  try {
    const response = await axios.request(options);
    return response.data;
  } catch (error) {
    console.error(error);
    return null;
  }
}

const TelegramUserStoryDL = async (link) => {
  const options = {
    method: 'GET',
    url: 'https://randydev-meta-ai.hf.space/user/get_story',
    params: {
      link: link
    }
  };
  try {
    const response = await axios.request(options);
    return response.data;
  } catch (error) {
    console.error(error);
    return null;
  }
}

const GetChatRaw = async (username) => {
  const options = {
    method: 'GET',
    url: 'https://randydev-meta-ai.hf.space/user/raw/getchat',
    params: {
      username: username
    }
  };
  try {
    const response = await axios.request(options);
    return response.data;
  } catch (error) {
    console.error(error);
    return null;
  }
}

const GetAuthorChat = async (username) => {
  const options = {
    method: 'GET',
    url: 'https://randydev-meta-ai.hf.space/user/author/admin',
    params: {
      username: username
    }
  };
  try {
    const response = await axios.request(options);
    return response.data;
  } catch (error) {
    console.error(error);
    return null;
  }
}

/**
 * @swagger
 * /api/v1/user/status/ban:
 *   get:
 *     summary: Telegram User Status Ban
 *     tags: [User]
 *     parameters:
 *       - in: query
 *         name: username
 *         required: true
 *         description: null
 *         schema:
 *           type: string
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
AntibanRoutes.get("/api/v1/user/status/ban", authenticateApiKey, apiLimiter, async (req, res) => {
    const Username = req.query.username;
    if (!Username) {
        return res.status(400).json({ error: "Invalid or missing username" });
    }
    try {
        const result = await TelegramUserStatusBan(Username);
        res.json(result);
    } catch (error) {
        res.status(500).json({ error: "Failed to fetch user info" });
    }
});

/**
 * @swagger
 * /api/v1/user/author/admin:
 *   get:
 *     summary: Telegram Author Admin
 *     tags: [User]
 *     parameters:
 *       - in: query
 *         name: username
 *         required: true
 *         description: null
 *         schema:
 *           type: string
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
AntibanRoutes.get("/api/v1/user/author/admin", authenticateApiKey, apiLimiter, async (req, res) => {
    const Username = req.query.username;
    if (!Username) {
        return res.status(400).json({ error: "Invalid or missing username" });
    }
    try {
        const result = await GetAuthorChat(Username);
        res.json(result);
    } catch (error) {
        res.status(500).json({ error: "Failed to fetch user info" });
    }
});


/**
 * @swagger
 * /api/v1/user/raw/getchat:
 *   get:
 *     summary: Telegram Get Chat
 *     tags: [User]
 *     parameters:
 *       - in: query
 *         name: username
 *         required: true
 *         description: null
 *         schema:
 *           type: string
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
AntibanRoutes.get("/api/v1/user/raw/getchat", authenticateApiKey, apiLimiter, async (req, res) => {
    const Username = req.query.username;
    if (!Username) {
        return res.status(400).json({ error: "Invalid or missing username" });
    }
    try {
        const result = await GetChatRaw(Username);
        res.json(result);
    } catch (error) {
        res.status(500).json({ error: "Failed to fetch user info" });
    }
});

/**
 * @swagger
 * /api/v1/user/story/task:
 *   get:
 *     summary: Telegram User Story Downloader
 *     tags: [User]
 *     parameters:
 *       - in: query
 *         name: story_url
 *         required: true
 *         description: Telegram Story URL to download
 *         schema:
 *           type: string
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Download started successfully
 */
AntibanRoutes.get("/api/v1/user/story/task", authenticateApiKey, apiLimiter, async (req, res) => {
    const Links = req.query.story_url;
    if (!Links) {
        return res.status(400).json({ error: "Invalid or missing story_url" });
    }

    const job_id = uuid.v4();
    const newJob = new Job({ job_id, status: "pending" });
    await newJob.save();
    setTimeout(async () => {
        try {
            const result = await TelegramUserStoryDL(Links);
            const story_bytes = result.download;

            await Job.findOneAndUpdate(
                { job_id },
                { status: "completed", story_bytes }
            );
        } catch (err) {
            await Job.findOneAndUpdate({ job_id }, { status: "failed" });
        }
    }, 10000);

    res.json({ message: "Download started", status: "processing", job_id });
});

/**
 * @swagger
 * /api/v1/user/story/task/{job_id}:
 *   delete:
 *     summary: Check Telegram User Story Delete Job ID
 *     tags: [User]
 *     parameters:
 *       - in: path
 *         name: job_id
 *         required: true
 *         description: Job ID to delete 
 *         schema:
 *           type: string
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Returns job Has been deleted
 */
AntibanRoutes.delete("/api/v1/user/story/task/:job_id", authenticateApiKey, apiLimiter, async (req, res) => {
    const { job_id } = req.params;
    
    const deletedJob = await Job.findOneAndDelete({ job_id });

    if (!deletedJob) {
        return res.status(404).json({ error: "Job not found" });
    }
    res.json({ message: "Job deleted successfully", job_id });
});


/**
 * @swagger
 * /api/v1/user/story/task/{job_id}:
 *   get:
 *     summary: Check Telegram User Story Download Status
 *     tags: [User]
 *     parameters:
 *       - in: path
 *         name: job_id
 *         required: true
 *         description: Job ID to check download status
 *         schema:
 *           type: string
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Returns job status and story bytes if completed
 */
AntibanRoutes.get("/api/v1/user/story/task/:job_id", authenticateApiKey, apiLimiter, async (req, res) => {
    const job = await Job.findOne({ job_id: req.params.job_id });

    if (!job) return res.status(404).json({ error: "Job not found" });

    res.json({
        job_id: job.job_id,
        status: job.status,
        story_bytes: job.status === "completed" ? job.story_bytes : null
    });
});

/**
 * @swagger
 * /api/v1/user/info:
 *   get:
 *     summary: Telegram User Info
 *     tags: [User]
 *     parameters:
 *       - in: query
 *         name: user_id
 *         required: true
 *         description: null
 *         schema:
 *           type: string
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
AntibanRoutes.get("/api/v1/user/info", authenticateApiKey, apiLimiter, async (req, res) => {
    const userId = req.query.user_id;
    if (!userId) {
        return res.status(400).json({ error: "Invalid or missing user_id" });
    }

    try {
        const result = await TelegramUser(userId);
        res.json(result);
    } catch (error) {
        res.status(500).json({ error: "Failed to fetch user info" });
    }
});


/**
 * @swagger
 * /api/v1/user/creation-date:
 *   get:
 *     summary: Telegram creation date User
 *     tags: [User]
 *     parameters:
 *       - in: query
 *         name: user_id
 *         required: true
 *         description: null
 *         schema:
 *           type: number
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
AntibanRoutes.get("/api/v1/user/creation-date", authenticateApiKey, apiLimiter, (req, res) => {
    const userId = Number(req.query.user_id);
    if (!userId || isNaN(userId)) {
        return res.status(400).json({ error: "Invalid or missing user_id" });
    }

    const result = predictCreationDate(userId);
    res.json({ user_id: userId, estimated_creation: result });
});

AntibanRoutes.get("/api/v1/user/api-key-info", authenticateApiKey, apiLimiter, async (req, res) => {
    const dbClient = new Database("AkenoXJs");
    const collectionKey = dbClient.collection("api_keys");
    const apiKey = req.headers["x-api-key"];
    try {
        if (!apiKey) {
            return res.status(400).json({ error: "Missing API key" });
        }
        const existingUserKey = await collectionKey.findOne({ key: apiKey });
        if (!existingUserKey) {
            return res.status(401).json({ message: "API key not found" });
        }
        res.json({ 
          owner_id: existingUserKey.owner,
          key: existingUserKey.key,
          ip_addresses: existingUserKey.ip_addresses || []
        });
    } catch (error) {
        res.status(500).json({ error: "Failed to fetch user info" });
    }
});

/**
 * @swagger
 * /api/v1/user/ban-user:
 *   post:
 *     summary: Telegram Ban User
 *     tags: [User]
 *     parameters:
 *       - in: query
 *         name: user_id
 *         required: true
 *         description: null
 *         schema:
 *           type: number
 *       - in: query
 *         name: reason
 *         required: false
 *         description: null
 *         schema:
 *           type: string
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
AntibanRoutes.post("/api/v1/user/ban-user", authenticateApiKey, apiLimiter, async (req, res) => {
    const dbClient = new Database("AkenoXJs");
    const collection = dbClient.collection("ban_users");
    const collectionKey = dbClient.collection("api_keys");
    try {
        const apiKey = req.headers["x-api-key"];
        const userIdString = req.query.user_id;
        const reasonString = req.query.reason;
        const userIdNumber = Number(userIdString);

        if (!apiKey) {
            return res.status(400).json({ error: "Missing API key in headers" });
        }
        if (isNaN(userIdNumber)) {
            return res.status(400).json({ error: "Invalid or missing user_id" });
        }

        const existingUserKey = await collectionKey.findOne({ key: apiKey });
        if (!existingUserKey) {
            return res.status(401).json({ message: "API key not found" });
        }

       /*
        if (existingUserKey.owner === userIdNumber) {
            return res.status(200).json({ 
              message: `User ${userIdNumber} cannot be banned because they created the API key`,
              is_ban: false
            });
        }
        */
    
        const result = await collectionKey.find({}).toArray();
        let userIds = [];
        for (const data of result) {
          if (data.owner !== undefined) {
            userIds.push(data.owner);
          }
        }

        /*
        if (userIds.includes(userIdNumber)) {
            return res.status(403).json({ 
              message: `User ${userIdNumber} cannot be banned because they created the API key`,
              is_ban: false 
            });
        }
        */

        if (protectedUsers.includes(userIdNumber)) {
            return res.status(403).json({ 
              message: `User ${userIdNumber} is a protected admin and cannot be banned`,
              is_ban: false 
            });
        }

        const existingBan = await collection.findOne({ user_ban: userIdNumber });
        if (existingBan) {
            return res.status(200).json({ message: `User ${userIdNumber} is already banned`, is_ban: true });
        }

        await collection.updateOne(
            { key: existingUserKey.key },
            { $addToSet: { user_ban: userIdNumber }, $set: { updatedAt: new Date(), owner: existingUserKey.owner } },
            { upsert: true }
        );

        res.json({ message: `User ${userIdNumber} successfully banned`, is_ban: true });

    } catch (error) {
        res.status(500).json({ error: `Internal server error: ${error.message}` });
    }
});

/**
 * @swagger
 * /api/v1/user/anti-broadcast:
 *   post:
 *     summary: Telegram Anti broadcast
 *     tags: [User]
 *     parameters:
 *       - in: query
 *         name: user_id
 *         required: true
 *         description: null
 *         schema:
 *           type: number
 *       - in: query
 *         name: text
 *         required: true
 *         description: null
 *         schema:
 *           type: string
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
AntibanRoutes.post("/api/v1/user/anti-broadcast", authenticateApiKey, async (req, res) => {
    const dbClient = new Database("AkenoXJs");
    const collection = dbClient.collection("users_broadcast");
    const collectionKey = dbClient.collection("api_keys");

    try {
        const apiKey = req.headers["x-api-key"];
        const userIdString = req.query.user_id;
        const WorldString = req.query.text;
        const userIdNumber = Number(userIdString);

        if (!apiKey) {
            return res.status(400).json({ error: "Missing API key in headers" });
        }
        if (!WorldString) {
            return res.status(400).json({ error: "Missing params: text" });
        }
        if (isNaN(userIdNumber)) {
            return res.status(400).json({ error: "Invalid or missing user_id" });
        }
        
        const existingUserKey = await collectionKey.findOne({ key: apiKey });

        if (!existingUserKey) {
            return res.status(401).json({ message: "API key not found" });
        }

        if (existingUserKey.owner === userIdNumber) {
            return res.status(200).json({ 
                message: `User ${userIdNumber} cannot be broadcast because they created the API key`,
                is_broadcast: false
            });
        }

        if (protectedUsers.includes(userIdNumber)) {
            return res.status(403).json({ 
              message: `User ${userIdNumber} is a protected admin and cannot be banned`,
              is_ban: false 
            });
        }

        const existingBroadcast = await collection.findOne({ user_id: userIdNumber });
        if (existingBroadcast) {
            return res.status(200).json({ message: `User ${userIdNumber} is already broadcasting`, is_broadcast: true });
        }

        if (WorldString.length > 3096) {
            return res.status(400).json({ message: `User ${userIdNumber} is sending a spam broadcast`, is_broadcast: true });
        }

        await collection.updateOne(
            { user_id: userIdNumber },
            { 
                $set: { 
                    text: WorldString, 
                    updatedAt: new Date(), 
                    owner: existingUserKey.owner, 
                    is_broadcast: true 
                } 
            },
            { upsert: true }
        );

        res.json({ message: `User ${userIdNumber} successfully broadcast`, is_broadcast: true });

    } catch (error) {
        res.status(500).json({ error: `Internal server error: ${error.message}` });
    }
});

/**
 * @swagger
 * /api/v1/user/check-broadcast:
 *   get:
 *     summary: Telegram Check Anti broadcast
 *     tags: [User]
 *     parameters:
 *       - in: query
 *         name: user_id
 *         required: true
 *         description: null
 *         schema:
 *           type: number
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
AntibanRoutes.get("/api/v1/user/check-broadcast", authenticateApiKey, async (req, res) => {
    const dbClient = new Database("AkenoXJs");
    const collection = dbClient.collection("users_broadcast");

    try {
        const userIdString = req.query.user_id;
        const userIdNumber = Number(userIdString);

        if (isNaN(userIdNumber)) {
            return res.status(400).json({ error: "Invalid or missing user_id" });
        }

        const GikesUser = await collection.findOne({ user_id: userIdNumber });

        if (GikesUser) {
            return res.status(200).json({ message: `User ${userIdNumber} is broadcast`, is_broadcast: true });
        } else {
            return res.status(200).json({ message: `User ${userIdNumber} is not broadcast`, is_broadcast: false });
        }

    } catch (error) {
        res.status(500).json({ error: `Internal server error: ${error.message}` });
    }
});

/**
 * @swagger
 * /api/v1/user/check-ban:
 *   get:
 *     summary: Telegram Check Banned
 *     tags: [User]
 *     parameters:
 *       - in: query
 *         name: user_id
 *         required: true
 *         description: null
 *         schema:
 *           type: number
 *       - in: header
 *         name: x-api-key
 *         required: true
 *         description: API key for authentication
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: Success
 */
AntibanRoutes.get("/api/v1/user/check-ban", authenticateApiKey, async (req, res) => {
    const dbClient = new Database("AkenoXJs");
    const collection = dbClient.collection("ban_users");

    try {
        const userIdString = req.query.user_id;
        const userIdNumber = Number(userIdString);

        if (isNaN(userIdNumber)) {
            return res.status(400).json({ error: "Invalid or missing user_id" });
        }

        const bannedUser = await collection.findOne({ user_ban: userIdNumber });

        if (bannedUser) {
            return res.status(200).json({ message: `User ${userIdNumber} is banned`, is_ban: true });
        } else {
            return res.status(200).json({ message: `User ${userIdNumber} is not banned`, is_ban: false });
        }

    } catch (error) {
        res.status(500).json({ error: `Internal server error: ${error.message}` });
    }
});

export { AntibanRoutes };