-
Notifications
You must be signed in to change notification settings - Fork 43
/
AIMr.py
108 lines (90 loc) · 3.27 KB
/
AIMr.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import os
import json
import shutil
import zipfile
import subprocess
import urllib.request
try:
newest_version = "https://raw.githubusercontent.com/kbdevs/ai-aimbot/main/current_version.txt"
req = urllib.request.Request(newest_version, headers={'Cache-Control': 'no-cache'})
response = urllib.request.urlopen(req)
remote_version = response.read().decode().strip()
file_paths = [
"./library.py",
"./yolo.cfg",
"./yolo.weights",
"./req.txt",
"./LICENSE",
"./README.md",
"./current_version.txt",
"./AIMr.py"
]
localv_path = "localv.json"
if not os.path.exists(localv_path) or not os.path.exists(file_paths[1]):
local_version = "0.0.0"
data = {
"version": remote_version,
"pip": False,
"first_launch": True
}
with open(localv_path, "w") as file:
json.dump(data, file)
else:
with open(localv_path, "r") as file:
data = json.load(file)
local_version = data["version"]
with open("localv.json", "r") as file:
data2 = json.load(file)
first_launch = data["first_launch"]
if first_launch is not True:
with open("localv.json", "r") as file:
data2 = json.load(file)
pip = data["pip"]
if pip is not True:
print("Installing required modules...")
os.system("pip install -r req.txt")
os.system("pip3 install -r req.txt")
with open("localv.json", "w") as file:
data2["pip"] = True
json.dump(data2, file)
os.remove(file_paths[3])
if remote_version != local_version:
print("Deleting old files...")
for file_path in file_paths:
if os.path.exists(file_path):
try:
os.remove(file_path)
except Exception as e:
print(f"Error occurred while removing {file_path}: {e}")
print("Downloading AIMr...")
# Download the zip file
url = "https://codeload.github.com/kbdevs/ai-aimbot/zip/refs/heads/main"
response = urllib.request.urlopen(url)
zip_content = response.read()
# Save the zip file
with open("ai-aimbot.zip", "wb") as file:
file.write(zip_content)
print("Unzipping...")
# Unzip the file
with zipfile.ZipFile("ai-aimbot.zip", "r") as zip_ref:
zip_ref.extractall("ai-aimbot")
os.remove("ai-aimbot.zip")
print("Moving files...")
# Move files from ai-aimbot/ to current directory
for root, dirs, files in os.walk("ai-aimbot"):
for file in files:
shutil.move(os.path.join(root, file), os.path.join(".", file))
# Remove ai-aimbot-testing/ directory
shutil.rmtree("ai-aimbot")
with open("localv.json", "w") as file:
data["version"] = remote_version
json.dump(data, file)
os.remove(file_paths[4])
os.remove(file_paths[5])
if os.path.exists("library.py"):
subprocess.run(["python", "library.py"])
else:
print("Failed to update, please delete localv.json and launch this again.")
exit()
except KeyboardInterrupt:
exit()