-
Notifications
You must be signed in to change notification settings - Fork 2
/
logs_gen.py
57 lines (51 loc) · 2.29 KB
/
logs_gen.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
from pymongo import MongoClient
client = MongoClient(
f"")
db = client.CTCrypt
logs_collection = db['answer-entry-log']
users = db['users']
log_data = logs_collection.find()
bait_answers = ['chocofactory', 'rafaleisback', 'neigermonk', 'notionpictures', 'clintonkamani', 'sansisthebestfont',
'battlegroundsmobileindia', 'doometernal2istheway', 'blenderfactory', 'rippedlabs']
cheaters = []
baited_ans = []
for user in log_data:
user_data = users.find_one({'_id': user['_id']})
level_count = 0
filename = "".join(x for x in user['username'] if (x.isalnum() or x in "._- "))
with open(f"logs/{filename}.txt", 'w') as user_file:
try:
user_file.writelines(f"""Name: {user_data['name']}
School: {user_data['organization']}
Discord: {user['username']}#{user['discriminator']}
Email: {user_data['email']}""")
except UnicodeEncodeError:
user_file.writelines(f"""Name: {user_data['name']}
School: {user_data['organization']}
Email: {user_data['email']}""")
while True:
try:
level_log = user[f'level{level_count}']
user_file.writelines(f"""\n--------
LEVEL {level_count}
--------""")
level_count += 1
for response in range(level_log['tries']):
try:
if level_log['responses'][f'response{response + 1}']['answer'] in bait_answers:
cheaters.append(user_data['_id'])
baited_ans.append(level_log['responses'][f'response{response + 1}']['answer'])
user_file.write(
f"\n[{level_log['responses'][f'response{response + 1}']['time']}] {level_log['responses'][f'response{response + 1}']['answer']}")
except UnicodeEncodeError:
user_file.write(
f"\n[{level_log['responses'][f'response{response + 1}']['time']}] Unidentified Character")
except KeyError:
break
with open('cheaters.txt', 'w') as paapi_list:
print('subhogay')
count = 0
for paapi in cheaters:
paapi_data = users.find_one({'_id': str(paapi)})
paapi_list.write(f"\n{paapi_data['username']}#{paapi_data['discriminator']} [{baited_ans[count]}]")
count += 1