Update plugins/antiban.js
Browse files- plugins/antiban.js +55 -0
plugins/antiban.js
CHANGED
@@ -7,6 +7,61 @@ const AntibanRoutes = express.Router();
|
|
7 |
|
8 |
const protectedUsers = [6477856957, 1191668125, 1448273246, 1054295664, 6444305696];
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
* @swagger
|
12 |
* /api/v1/user/creation-date:
|
|
|
7 |
|
8 |
const protectedUsers = [6477856957, 1191668125, 1448273246, 1054295664, 6444305696];
|
9 |
|
10 |
+
const TelegramUser = async (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, async (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 |
+
try {
|
57 |
+
const result = await TelegramUser(userId);
|
58 |
+
res.json(result);
|
59 |
+
} catch (error) {
|
60 |
+
res.status(500).json({ error: "Failed to fetch user info" });
|
61 |
+
}
|
62 |
+
});
|
63 |
+
|
64 |
+
|
65 |
/**
|
66 |
* @swagger
|
67 |
* /api/v1/user/creation-date:
|