Skip to content

Commit 72f7798

Browse files
committed
Version 0.2
1 parent b43a08d commit 72f7798

12 files changed

Lines changed: 395 additions & 96 deletions

File tree

CodeBreak.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
from config.config import *
77
from config.menu import *
88
from menu.discordAnim import discordAnim
9-
import colorama, os
10-
except:
11-
print('Erreur import module in CodeBreak.py')
9+
import os
10+
except Exception as e :
11+
errorModule(e)
1212

1313
terminalTitle('MainMenu')
14-
colorama.init()
1514
checkUpdate()
1615

1716
while True:
@@ -27,7 +26,7 @@
2726
elif select == '3':
2827
discordAnim('nukeBot.py')
2928
elif select == '4':
30-
Soon()
29+
startProgram('infoServerDisc.py')
3130
elif select == '5':
3231
Soon()
3332
elif select == '6':

config/config.py

Lines changed: 140 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,31 @@
33
# Tous droits réservés.
44

55
try:
6-
import colorama, json, subprocess, os, sys, datetime, requests, webbrowser
6+
import colorama, json, subprocess, os, sys, datetime, requests, webbrowser, platform
77
from config.info import *
8+
from colorama import Fore, Style
89
except Exception as error:
910
import os
1011
print(f'Error in Module : {error}')
1112
os.system("pause")
1213

14+
data = {}
1315
colorama.init()
1416
color = colorama.Fore
15-
reset = color.RESET
17+
reset = Style.RESET_ALL
1618
purple = '\033[38;2;131;0;255m'
19+
lightPurple = '\033[38;2;178;102;255m'
20+
pink = '\033[38;2;255;105;180m'
21+
lightBlue = '\033[38;2;173;216;230m'
22+
lightLilac = '\033[38;2;200;162;200m'
1723
white = color.WHITE
1824
yellow = color.YELLOW
1925
blue = color.BLUE
2026
red = color.RED
2127
green = color.GREEN
22-
23-
parametreFichier = 'config/parametre.json'
28+
bold = Style.BRIGHT
29+
dim = Style.DIM
30+
normal = Style.NORMAL
2431

2532
def githubVersion():
2633
response = requests.get(linkUpdate)
@@ -54,55 +61,24 @@ def checkUpdate():
5461
# else:
5562
# pass
5663

57-
def Sauvegarde() :
58-
try:
59-
with open(parametreFichier, 'w') as fichier:
60-
json.dump(data, fichier, indent=4)
61-
except FileNotFoundError:
62-
print(f'{red}[{white}x{red}] The file {parametreFichier} is not found. {reset}')
63-
os.system('pause')
64-
except Exception as error:
65-
print(f'{red}[{white}x{red}] An error occurred while saving the settings: {yellow}{error}{reset}')
66-
os.system('pause')
67-
68-
try:
69-
with open(parametreFichier, 'r') as fichier:
70-
data = json.load(fichier)
71-
except FileNotFoundError:
72-
print(f'{red}[{white}x{red}] The file {parametreFichier} is not found. {reset}')
73-
os.system('pause')
74-
except json.JSONDecodeError:
75-
print(f'{red}[{white}x{red}] JSON decoding error in the file {parametreFichier}. {reset}')
76-
os.system('pause')
77-
except Exception as error:
78-
print(f'{red}[{white}x{red}] An error occurred while loading the settings: {yellow}{error}{reset}')
79-
os.system('pause')
80-
81-
def setPromptColor(setting):
64+
def setPromptColor():
8265
global promptColor
83-
if setting['promptColor'] == 'white':
66+
if data['promptColor'] == 'white':
8467
promptColor = white
85-
elif setting['promptColor'] == 'yellow':
68+
elif data['promptColor'] == 'yellow':
8669
promptColor = yellow
87-
elif setting['promptColor'] == 'blue':
70+
elif data['promptColor'] == 'blue':
8871
promptColor = blue
89-
elif setting['promptColor'] == 'red':
72+
elif data['promptColor'] == 'red':
9073
promptColor = red
91-
elif setting['promptColor'] == 'green':
74+
elif data['promptColor'] == 'green':
9275
promptColor = green
93-
elif setting['promptColor'] == 'purple':
76+
elif data['promptColor'] == 'purple':
9477
promptColor = purple
9578
else:
9679
promptColor = white
9780
print(f'{ERROR} Unknown prompt color: {data['promptColor']}. Using default white.')
98-
os.system('pause')
99-
100-
setPromptColor(data)
101-
102-
try:
103-
username = os.getlogin()
104-
except:
105-
username = 'user'
81+
Pause()
10682

10783
def TIME_H():
10884
return datetime.datetime.now().strftime('%H:%M:%S')
@@ -144,9 +120,26 @@ def startMenu(program):
144120
elif sys.platform.startswith("linux"):
145121
file = f'python3 menu/{program}'
146122
subprocess.run(file, shell=True)
123+
124+
def errorModule(error):
125+
print(f'{TIME_RED()} {ERROR} Error Module (Restart install.bat) or contact support on the discord server : {yellow}{error}{reset}')
126+
webbrowser.open(linkDiscord)
127+
Pause()
128+
mainMenu()
129+
130+
def error(error):
131+
print(f"\n{TIME_RED()} {ERROR} Error : {yellow}{error}{reset}")
132+
Pause()
133+
mainMenu()
134+
135+
def errorUrl():
136+
print(f"\n{TIME_RED()} {ERROR} Invalid URL ! {reset}")
137+
Pause()
138+
mainMenu()
147139

148140
def Pause():
149141
input(f"{TIME()} {WAIT} Press to continue >>> {reset}")
142+
150143
def Soon():
151144
print(f'{TIME_YELLOW()} {INFO_YELLOW} The chosen option will arrive soon. {reset}')
152145
Pause()
@@ -194,10 +187,112 @@ def TIME_YELLOW():
194187
{"num": 3, "titre": "NukeBot Discord"},
195188
{"num": 8, "titre": "Soon"},
196189
{"num": 13, "titre": "Soon"},
197-
{"num": 4, "titre": "Soon"},
190+
{"num": 4, "titre": "Discord Invitation Info"},
198191
{"num": 9, "titre": "Soon"},
199192
{"num": 14, "titre": "Soon"},
200193
{"num": 5, "titre": "Soon"},
201194
{"num": 10, "titre": "Soon"},
202195
{"num": 15, "titre": "Soon"},
203-
]
196+
]
197+
def Sauvegarde() :
198+
try:
199+
save_dir = setDirectory()
200+
filePath = os.path.join(save_dir, 'Save.json')
201+
with open(filePath, 'w') as fichier:
202+
json.dump(data, fichier, indent=4)
203+
except FileNotFoundError:
204+
print(f'{TIME_RED()} {ERROR} The file {filePath} is not found. {reset}')
205+
Pause()
206+
except Exception as error:
207+
print(f'{TIME_RED()} {ERROR} An error occurred while saving the settings: {yellow}{error}{reset}')
208+
Pause()
209+
210+
def setDirectory():
211+
if platform.system() == 'Windows':
212+
documents_folder = os.path.join(os.path.expanduser('~'), 'Documents')
213+
return os.path.join(documents_folder, 'CodeBreak')
214+
elif platform.system() == 'Linux':
215+
return os.path.join(os.path.expanduser('~'), '.local', 'share', 'CodeBreak')
216+
elif platform.system() == 'Darwin':
217+
library_folder = os.path.join(os.path.expanduser('~'), 'Library', 'Application Support')
218+
return os.path.join(library_folder, 'CodeBreak')
219+
else:
220+
raise OSError(f"{TIME_RED()} {ERROR} Système d'exploitation non supporté{reset}")
221+
222+
def saveDirectory(path):
223+
try:
224+
os.makedirs(path, exist_ok=True)
225+
except Exception as e:
226+
print(f'{TIME_RED()} {ERROR} Erreur lors de la création du dossier {path}: {e} {reset}')
227+
Pause()
228+
229+
def loadData(saveFile):
230+
if os.path.exists(saveFile):
231+
try :
232+
with open(saveFile, 'r') as fichier:
233+
data = json.load(fichier)
234+
if not isinstance(data, dict):
235+
return {}
236+
return data
237+
except FileNotFoundError:
238+
print(f'{TIME_RED()} {ERROR} The file {saveFile} is not found. {reset}')
239+
except json.JSONDecodeError:
240+
print(f'{TIME_RED()} {ERROR} JSON decoding error in the file {saveFile}. {reset}')
241+
except Exception as error:
242+
print(f'{TIME_RED()} {ERROR} An error occurred while loading the settings: {yellow}{error}{reset}')
243+
return defaultData
244+
else:
245+
return defaultData
246+
247+
def FirstSauvegarde(file_path, data):
248+
try:
249+
with open(file_path, 'w') as fichier:
250+
json.dump(data, fichier, indent=4)
251+
except Exception as error:
252+
print(f'{TIME_RED()} {ERROR} Une erreur est survenue lors de la sauvegarde des paramètres : {yellow}{error}{reset}')
253+
Pause()
254+
255+
def upData(existing_data, newData):
256+
if isinstance(existing_data, dict) and isinstance(newData, dict):
257+
for key, value in newData.items():
258+
if key not in existing_data:
259+
existing_data[key] = value
260+
else:
261+
print(f'{TIME_RED()} {ERROR} Les données existantes ou nouvelles ne sont pas des dictionnaires.{reset}')
262+
return existing_data
263+
264+
265+
try:
266+
username = os.getlogin()
267+
except:
268+
username = 'user'
269+
270+
defaultData = {
271+
"promptColor": "purple",
272+
"token": "null",
273+
"excludeIds": [
274+
"726772485252710503"
275+
],
276+
"censureToken": "False"
277+
}
278+
279+
def main():
280+
global data
281+
282+
try :
283+
save_dir = setDirectory()
284+
save_file_path = os.path.join(save_dir, 'Save.json')
285+
saveDirectory(save_dir)
286+
existing_data = loadData(save_file_path)
287+
data = upData(existing_data, defaultData)
288+
FirstSauvegarde(save_file_path, data)
289+
except Exception as error:
290+
print(f'{TIME_RED()} {ERROR} error loading/writing backup : {error} {reset}')
291+
Pause()
292+
293+
try:
294+
setPromptColor()
295+
except Exception as error:
296+
print(f'{TIME_RED()} {ERROR} error setPromptColor : {error} {reset}')
297+
Pause()
298+
main()

config/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# General Information
66
creator = 'Cipix'
7-
versionCode = '0.1'
7+
versionCode = '0.2'
88
# Link
99
linkDiscord = 'https://discord.gg/pZSVzVkXBR'
1010
linkGithub = 'https://github.com/CIPIX-off/CodeBreak'

config/menu.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
# All rights reserved.
33
# Tous droits réservés.
44

5-
import colorama
65
from config.config import *
7-
from config.info import *
86

9-
colorama.init()
7+
try :
8+
from config.info import *
9+
except Exception as e :
10+
errorModule(e)
1011

1112
TITLE = f"""{purple}
1213
▄████▄ ▒█████ ▓█████▄ ▓█████ ▄▄▄▄ ██▀███ ▓█████ ▄▄▄ ██ ▄█▀

config/parametre.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

menu/discordAnim.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
import time, os, sys
2-
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
3-
from config.config import *
1+
# © 2024 CIPIX
2+
# All rights reserved.
3+
# Tous droits réservés.
4+
5+
try :
6+
import time, os, sys
7+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8+
from config.config import *
9+
except Exception as e :
10+
errorModule(e)
411

512
temps = 0.1
613
colorDiscord = blue

menu/setting.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
# All rights reserved.
33
# Tous droits réservés.
44

5-
import colorama, sys, os
6-
colorama.init()
7-
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8-
from config.config import *
9-
from config.menu import *
5+
try :
6+
import sys, os
7+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8+
from config.config import *
9+
from config.menu import *
10+
except Exception as e :
11+
errorModule(e)
12+
1013
terminalTitle('Setting')
1114

1215
SettingOption = [

program/censorToken.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
# All rights reserved.
33
# Tous droits réservés.
44

5-
import colorama, sys, os
6-
colorama.init()
7-
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8-
from config.config import *
9-
from config.menu import *
5+
try :
6+
import sys, os
7+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8+
from config.config import *
9+
from config.menu import *
10+
except Exception as e :
11+
errorModule(e)
12+
1013
terminalTitle('Setting/Censor token')
1114

1215
while True :

program/info.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
# All rights reserved.
33
# Tous droits réservés.
44

5-
import colorama, sys, os
6-
colorama.init()
7-
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8-
from config.config import *
9-
from config.menu import *
10-
from config.info import *
11-
terminalTitle('Info')
5+
try :
6+
import sys, os
7+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8+
from config.config import *
9+
from config.menu import *
10+
from config.info import *
11+
except Exception as e :
12+
errorModule(e)
1213

14+
terminalTitle('Info')
1315
def english():
1416
print(f"""
1517
{TIME_YELLOW()} {INFO_YELLOW} Information :

0 commit comments

Comments
 (0)