randydev commited on
Commit
3f354c6
·
verified ·
1 Parent(s): 33a61f3

Update plugins/antiban.js

Browse files
Files changed (1) hide show
  1. plugins/antiban.js +51 -0
plugins/antiban.js CHANGED
@@ -1,4 +1,5 @@
1
  import express from 'express';
 
2
  import { Database } from '../database/database.js';
3
  import { predictCreationDate } from '../lib/create-date.js';
4
  import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
@@ -6,6 +7,56 @@ const AntibanRoutes = express.Router();
6
 
7
  const protectedUsers = [6477856957, 1191668125, 1448273246, 1054295664, 6444305696];
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  /**
10
  * @swagger
11
  * /api/v1/user/creation-date:
 
1
  import express from 'express';
2
+ import axios from 'axios';
3
  import { Database } from '../database/database.js';
4
  import { predictCreationDate } from '../lib/create-date.js';
5
  import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
 
7
 
8
  const protectedUsers = [6477856957, 1191668125, 1448273246, 1054295664, 6444305696];
9
 
10
+ async function TelegramUser(user_id) {
11
+ const options = {
12
+ method: 'GET',
13
+ url: 'https://randydev-meta-ai.hf.space',
14
+ params: {
15
+ user_id: user_id
16
+ }
17
+ };
18
+ try {
19
+ const response = await axios.request(options);
20
+ return response.data;
21
+ } catch (error) {
22
+ console.error(error);
23
+ return null;
24
+ }
25
+ }
26
+
27
+ /**
28
+ * @swagger
29
+ * /api/v1/user/info:
30
+ * get:
31
+ * summary: Telegram User Info
32
+ * tags: [User]
33
+ * parameters:
34
+ * - in: query
35
+ * name: user_id
36
+ * required: true
37
+ * description: null
38
+ * schema:
39
+ * type: number
40
+ * - in: header
41
+ * name: x-api-key
42
+ * required: true
43
+ * description: API key for authentication
44
+ * schema:
45
+ * type: string
46
+ * responses:
47
+ * 200:
48
+ * description: Success
49
+ */
50
+ AntibanRoutes.get("/api/v1/user/info", authenticateApiKey, apiLimiter, (req, res) => {
51
+ const userId = req.query.user_id;
52
+ if (!userId) {
53
+ return res.status(400).json({ error: "Invalid or missing user_id" });
54
+ }
55
+
56
+ const result = TelegramUser(userId);
57
+ res.json(result);
58
+ });
59
+
60
  /**
61
  * @swagger
62
  * /api/v1/user/creation-date: