-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
36 lines (25 loc) · 724 Bytes
/
util.py
File metadata and controls
36 lines (25 loc) · 724 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
32
33
34
35
36
from mod_repltalk import client
def verify_headers(headers):
name = headers.get("X-Replit-User-Name")
roles = headers.get("X-Replit-User-Roles")
if name:
return "moderator" in roles.split(",")
else:
return None
async def _ban(username, reason):
user = await client.get_user(username)
if str(user) != 'None':
posts = await user.get_posts()
while len(list(posts)) > 0:
for post in posts:
await post.delete()
posts = await user.get_posts()
comments = await user.get_comments()
while len(list(comments)) > 0:
for comment in comments:
await comment.delete()
comments = await user.get_comments()
await user.ban(reason)
return True
else:
return False