-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathallow.py
More file actions
39 lines (33 loc) · 1.11 KB
/
allow.py
File metadata and controls
39 lines (33 loc) · 1.11 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
def LoadAllow():
try:
with open('data/allow.txt') as file:
models = [row.strip().lower() for row in file]
except Exception as e:
return e
return models
def CheckAllow(userid):
if str(userid) in LoadAllow():
return True
else:
return False
def AddAllow(userid):
if str(userid) in LoadAllow():
return f'Пользователь есть в этом списке.'
try:
with open('data/allow.txt', 'a') as file:
file.write(f'\n{userid}')
except Exception as e:
return e
return f'Пользователь {userid} успешно добавлен.'
def DeleteAllow(userid):
userlist = LoadAllow()
if str(userid) not in userlist:
return f'Пользователь не найден.'
userlist.remove(userid)
try:
with open('data/allow.txt', 'w') as file:
for row in userlist:
file.write(f'{row}\n')
except Exception as e:
return e
return f'Пользователь {userid} успешно удалён.'