-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.py
More file actions
55 lines (42 loc) · 1.77 KB
/
Copy pathtest2.py
File metadata and controls
55 lines (42 loc) · 1.77 KB
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
from pymongo import MongoClient
from Connection import Connection
cluster = MongoClient(
"mongodb+srv://Logan:lolo123@cluster0.igyjs.mongodb.net/ecole?retryWrites=true&w=majority")
db = cluster.testdb
collection = db.testcollection
roles = db.roles
class ManageRole(Connection):
def __init__(self, username, password=''):
Connection.__init__(self, username, password)
def remove_role(self, role):
self.role = role
roles.delete_one({"Role": self.role})
delete_from_all_user = collection.find({})
for user in delete_from_all_user:
for key, values in user.items():
if key == "role":
self.dic_user = user
self.role_of_the_user = values
if role in self.role_of_the_user:
self.role_of_the_user.remove(role)
self.dic_user["role"] = self.role_of_the_user
print(type(self.role_of_the_user), self.dic_user)
collection.replace_one({"username": self.dic_user["username"]}, self.dic_user)
return True
else:
return False
def add_role(self, role):
self.role = role
roles.insert_one({"Role": self.role})
def add_role_to_user(self, myself, target):
self.myself = myself
self.target = target
role_of_the_target = collection.find({"username" : self.target})["role"]
print(role_of_the_target)
def music_bot(self):
list_autorized = ["ADMIN", "DJ"]
def add_role_to_admin(self, new_role):
def add_role_to_modo(self, new_role):
def
a = ManageRole("bedus", "Zink")
a.add_role_to_user("DJ")