-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
62 lines (56 loc) · 2.05 KB
/
setup.py
File metadata and controls
62 lines (56 loc) · 2.05 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
56
57
58
59
60
61
62
import os
import sys
import json
config = {
"session": "",
"username": "",
"target_user": "",
"whitelistEnabled": False,
"whitelist": [],
"runAsAdmin": False
}
def run_server():
if sys.platform == "win32":
if config["runAsAdmin"]:
os.system('powershell -Command "Start-Process python -ArgumentList \'server.py\' -Verb RunAs"')
else:
os.system('python server.py')
elif sys.platform == "linux" or sys.platform == "darwin":
if config["runAsAdmin"]:
os.system('sudo python3 server.py')
else:
os.system('python3 server.py')
else:
print("Unsupported OS.")
def main():
if os.path.exists('config.json'):
print("Found config.json, starting server...")
run_server()
else:
print("No config.json found, running setup...")
print("Installing packages...")
os.system('pip install scratchattach')
print("Setup:")
config["session"] = input("Enter your session id (get it from https://scratch.mit.edu/): ")
config["username"] = input("Enter your Scratch username: ")
config["target_user"] = input("Enter the username of the account you want to monitor comments on: ")
admin = input("Do you want to run the server as admin? (y/n): ")
if admin.lower() == "y":
config["runAsAdmin"] = True
else:
config["runAsAdmin"] = False
whitelist = input("Do you want to enable the whitelist? (y/n): ")
if whitelist.lower() == "y":
config["whitelistEnabled"] = True
print("Enter the usernames you want to whitelist, one per line. Enter a blank line to finish.")
while True:
user = input("Username: ")
if user == "":
break
config["whitelist"].append(user)
with open('config.json', 'w') as f:
json.dump(config, f, indent=4)
print("Setup complete! Starting server...")
run_server()
if __name__ == "__main__":
main()