-
Notifications
You must be signed in to change notification settings - Fork 19
/
users.py
61 lines (50 loc) · 1.63 KB
/
users.py
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
# Edit line 23 "ez4short.com" with your shortener website link
from motor.motor_asyncio import *
from config import *
from domainers import *
client = AsyncIOMotorClient(DATABASE_URL)
db = client[DATABASE_NAME]
col = db["users"]
async def get_user(user_id):
user_id = int(user_id)
user = await col.find_one({"user_id": user_id})
if not user:
res = {
"user_id": user_id,
"method":"MdiskPro",
"shortener_api": None,
"mdisk_api": None,
"header_text": "",
"footer_text": "",
"username": "None",
"base_site": "ez4short.com",
"banner_image": None,
"is_banner_image": True,
"is_username": True,
"is_header_text": True,
"is_footer_text": True,
"include_domain": [],
"exclude_domain": [],
"banned": False
}
await col.insert_one(res)
user = await col.find_one({"user_id": user_id})
return user
async def update_user_info(user_id, value:dict, tag="$set"):
user_id = int(user_id)
myquery = {"user_id": user_id}
newvalues = {tag : value }
await col.update_one(myquery, newvalues)
async def filter_users(dict):
return col.find(dict)
async def total_users_count():
return await col.count_documents({})
async def get_all_users():
return col.find({})
async def delete_user(user_id):
await col.delete_one({'user_id': int(user_id)})
async def total_users_count():
return await col.count_documents({})
async def is_user_exist(id):
user = await col.find_one({'user_id':int(id)})
return bool(user)