forked from swatv3nub/PyrogramBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgbansdb
More file actions
33 lines (21 loc) · 736 Bytes
/
gbansdb
File metadata and controls
33 lines (21 loc) · 736 Bytes
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
from PyrogramBot import db
gbansdb = db.gban
async def get_gbans_count() -> int:
users = gbansdb.find({"user_id": {"$gt": 0}})
users = await users.to_list(length=100000)
return len(users)
async def is_gbanned_user(user_id: int) -> bool:
user = await gbansdb.find_one({"user_id": user_id})
if not user:
return False
return True
async def add_gban_user(user_id: int):
is_gbanned = await is_gbanned_user(user_id)
if is_gbanned:
return
return await gbansdb.insert_one({"user_id": user_id})
async def remove_gban_user(user_id: int):
is_gbanned = await is_gbanned_user(user_id)
if not is_gbanned:
return
return await gbansdb.delete_one({"user_id": user_id})