randydev commited on
Commit
90fae10
·
verified ·
1 Parent(s): caa8423

Update plugins/antiban.js

Browse files
Files changed (1) hide show
  1. plugins/antiban.js +86 -4
plugins/antiban.js CHANGED
@@ -11,7 +11,7 @@ const protectedUsers = [6477856957, 1191668125, 1448273246, 1054295664, 64443056
11
  * /api/v1/user/creation-date:
12
  * get:
13
  * summary: Telegram creation date User
14
- * tags: [User]
15
  * parameters:
16
  * - in: query
17
  * name: user_id
@@ -42,9 +42,9 @@ AntibanRoutes.get("/api/v1/user/creation-date", authenticateApiKey, apiLimiter,
42
  /**
43
  * @swagger
44
  * /api/v1/user/ban-user:
45
- * get:
46
  * summary: Telegram Ban User
47
- * tags: [User]
48
  * parameters:
49
  * - in: query
50
  * name: user_id
@@ -52,7 +52,7 @@ AntibanRoutes.get("/api/v1/user/creation-date", authenticateApiKey, apiLimiter,
52
  * description: null
53
  * schema:
54
  * type: number
55
- * - in: query
56
  * name: reason
57
  * required: false
58
  * description: null
@@ -122,6 +122,35 @@ AntibanRoutes.post("/api/v1/user/ban-user", authenticateApiKey, apiLimiter, asyn
122
  }
123
  });
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  AntibanRoutes.post("/api/v1/user/anti-broadcast", authenticateApiKey, async (req, res) => {
126
  const dbClient = new Database("AkenoXJs");
127
  const collection = dbClient.collection("users_broadcast");
@@ -156,6 +185,13 @@ AntibanRoutes.post("/api/v1/user/anti-broadcast", authenticateApiKey, async (req
156
  });
157
  }
158
 
 
 
 
 
 
 
 
159
  const existingBroadcast = await collection.findOne({ user_id: userIdNumber });
160
  if (existingBroadcast) {
161
  return res.status(200).json({ message: `User ${userIdNumber} is already broadcasting`, is_broadcast: true });
@@ -185,6 +221,29 @@ AntibanRoutes.post("/api/v1/user/anti-broadcast", authenticateApiKey, async (req
185
  }
186
  });
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  AntibanRoutes.get("/api/v1/user/check-broadcast", authenticateApiKey, async (req, res) => {
189
  const dbClient = new Database("AkenoXJs");
190
  const collection = dbClient.collection("users_broadcast");
@@ -210,6 +269,29 @@ AntibanRoutes.get("/api/v1/user/check-broadcast", authenticateApiKey, async (req
210
  }
211
  });
212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  AntibanRoutes.get("/api/v1/user/check-ban", authenticateApiKey, async (req, res) => {
214
  const dbClient = new Database("AkenoXJs");
215
  const collection = dbClient.collection("ban_users");
 
11
  * /api/v1/user/creation-date:
12
  * get:
13
  * summary: Telegram creation date User
14
+ * tags: [User]
15
  * parameters:
16
  * - in: query
17
  * name: user_id
 
42
  /**
43
  * @swagger
44
  * /api/v1/user/ban-user:
45
+ * post:
46
  * summary: Telegram Ban User
47
+ * tags: [User]
48
  * parameters:
49
  * - in: query
50
  * name: user_id
 
52
  * description: null
53
  * schema:
54
  * type: number
55
+ * - in: query
56
  * name: reason
57
  * required: false
58
  * description: null
 
122
  }
123
  });
124
 
125
+ /**
126
+ * @swagger
127
+ * /api/v1/user/anti-broadcast:
128
+ * post:
129
+ * summary: Telegram Anti broadcast
130
+ * tags: [User]
131
+ * parameters:
132
+ * - in: query
133
+ * name: user_id
134
+ * required: true
135
+ * description: null
136
+ * schema:
137
+ * type: number
138
+ * - in: query
139
+ * name: text
140
+ * required: true
141
+ * description: null
142
+ * schema:
143
+ * type: string
144
+ * - in: header
145
+ * name: x-api-key
146
+ * required: true
147
+ * description: API key for authentication
148
+ * schema:
149
+ * type: string
150
+ * responses:
151
+ * 200:
152
+ * description: Success
153
+ */
154
  AntibanRoutes.post("/api/v1/user/anti-broadcast", authenticateApiKey, async (req, res) => {
155
  const dbClient = new Database("AkenoXJs");
156
  const collection = dbClient.collection("users_broadcast");
 
185
  });
186
  }
187
 
188
+ if (protectedUsers.includes(userIdNumber)) {
189
+ return res.status(403).json({
190
+ message: `User ${userIdNumber} is a protected admin and cannot be banned`,
191
+ is_ban: false
192
+ });
193
+ }
194
+
195
  const existingBroadcast = await collection.findOne({ user_id: userIdNumber });
196
  if (existingBroadcast) {
197
  return res.status(200).json({ message: `User ${userIdNumber} is already broadcasting`, is_broadcast: true });
 
221
  }
222
  });
223
 
224
+ /**
225
+ * @swagger
226
+ * /api/v1/user/check-broadcast:
227
+ * get:
228
+ * summary: Telegram Check Anti broadcast
229
+ * tags: [User]
230
+ * parameters:
231
+ * - in: query
232
+ * name: user_id
233
+ * required: true
234
+ * description: null
235
+ * schema:
236
+ * type: number
237
+ * - in: header
238
+ * name: x-api-key
239
+ * required: true
240
+ * description: API key for authentication
241
+ * schema:
242
+ * type: string
243
+ * responses:
244
+ * 200:
245
+ * description: Success
246
+ */
247
  AntibanRoutes.get("/api/v1/user/check-broadcast", authenticateApiKey, async (req, res) => {
248
  const dbClient = new Database("AkenoXJs");
249
  const collection = dbClient.collection("users_broadcast");
 
269
  }
270
  });
271
 
272
+ /**
273
+ * @swagger
274
+ * /api/v1/user/check-ban:
275
+ * get:
276
+ * summary: Telegram Check Banned
277
+ * tags: [User]
278
+ * parameters:
279
+ * - in: query
280
+ * name: user_id
281
+ * required: true
282
+ * description: null
283
+ * schema:
284
+ * type: number
285
+ * - in: header
286
+ * name: x-api-key
287
+ * required: true
288
+ * description: API key for authentication
289
+ * schema:
290
+ * type: string
291
+ * responses:
292
+ * 200:
293
+ * description: Success
294
+ */
295
  AntibanRoutes.get("/api/v1/user/check-ban", authenticateApiKey, async (req, res) => {
296
  const dbClient = new Database("AkenoXJs");
297
  const collection = dbClient.collection("ban_users");