-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscratch-verify.py
30 lines (26 loc) · 949 Bytes
/
scratch-verify.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
import random
import string
from time import sleep
import requests
def createCode() -> str:
return "".join(random.SystemRandom().choices(string.digits, k = 32))
def verifyCode(username: str, code: str) -> bool:
cloudData = requests.get("https://clouddata.scratch.mit.edu/logs", params = {"projectid": 440710593, "limit": 1000, "offset": 0}).json()
for entry in cloudData:
if (entry["verb"] == "set_var" and entry["name"] == "☁ Verification code" and entry["user"] == username):
# print(entry)
if entry['value'] == code:
return True
else:
return False
return False
if __name__ == "__main__":
uname = str(input("What username do you want to check for? "))
vcode = createCode()
print("Your code is:", str(vcode), "\nWaiting for you to enter the code in the project...")
done = False
while not done:
done = verifyCode(uname, vcode)
if not done:
sleep(0.5)
print("Verified!")