-
Notifications
You must be signed in to change notification settings - Fork 17
/
whatsappbomber.py
703 lines (527 loc) · 26 KB
/
whatsappbomber.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
#############
# LIBRARIES #
#############
import sys
import colorama
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
import time
import os
import platform
from colorama import Fore, init as colorama_init
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.firefox import GeckoDriverManager
###########################
# LIBRARY INITIALIZATIONS #
###########################
colorama_init(autoreset=True)
#############
# VARIABLES #
#############
enable_logs = True
#############
# CONSTANTS #
#############
URL = "https://web.whatsapp.com/"
OS = platform.system()
TERMINAL_SIZE = os.get_terminal_size()
VERSION = "0.6.8"
# Utility colors
COLOR_COLON = Fore.CYAN
COLOR_LINE_SEPARATOR = Fore.MAGENTA
COLOR_PROMPT = Fore.YELLOW
COLOR_TITLE = Fore.GREEN
COLOR_INPUT = Fore.MAGENTA
COLOR_LOG_INFO = Fore.YELLOW
COLOR_LOG_ERROR = Fore.RED
COLOR_LOG_SUCCESS = Fore.GREEN
COLOR_INPUT_DELIMITER = Fore.LIGHTBLUE_EX
# APP TITLE COLORS
APP_VERSION_COLOR = Fore.YELLOW
APP_INPUT_COLOR = Fore.LIGHTYELLOW_EX
APP_INPUT_SEPARATOR_COLOR = Fore.BLUE
# MAIN MENU COLORS
MAIN_MENU_TITLE_COLOR = Fore.BLUE
MAIN_MENU_OPTIONS_NUMBER_COLOR = Fore.LIGHTBLUE_EX
MAIN_MENU_OPTIONS_TEXT_COLOR = Fore.LIGHTMAGENTA_EX
MAIN_MENU_DISCLAIMER_WARNING_COLOR = Fore.RED
MAIN_MENU_EXIT_MESSAGE_COLOR = Fore.YELLOW
# Webdriver
WEBDRIVER_WAIT_TIMEOUT = 60
#############
# FUNCTIONS #
#############
def get_input(message: str) -> str:
# Get input
result = input(COLOR_PROMPT + message + f"{COLOR_COLON}:\n {COLOR_INPUT_DELIMITER}-> {COLOR_INPUT}")
# Reset the color
print("", end=Fore.RESET)
# Return the input
return result
def log(level: str, message: str, hierarchy_level=0) -> None:
if enable_logs:
# Color if no defined level
color = Fore.WHITE
# Check the level and assign the respective colors to color
if level.lower() == "info":
color = COLOR_LOG_INFO
elif level.lower() == "error":
color = COLOR_LOG_ERROR
elif level.lower() == "success":
color = COLOR_LOG_SUCCESS
# New line length for when there is a new line in message
new_line_length = len(level) + 4
# Split messages into lines
messages = message.split("\n")
# Calculating amount of space to print for hierarchy
hierarchy_space = " " * (4 * hierarchy_level) if hierarchy_level > 0 else ""
# Loop through the list of messages
for i, msg in enumerate(messages):
# If first time printing message
if i == 0:
# print the message with the level
pretty_print(f"{hierarchy_space}{color}[ {level.upper()} ] {msg.title()}", align="left", back_separator=False, front_separator=False)
else:
# ignore the level and print the message only
pretty_print(f" " * new_line_length + f"{hierarchy_space}" + f"{Fore.YELLOW} {msg.title()}")
def clear_screen() -> None:
if OS.lower().startswith("win"):
os.system("cls")
else:
os.system("clear")
def separate_line() -> None:
columns = os.get_terminal_size().columns
print(f"{Fore.CYAN}| {COLOR_LINE_SEPARATOR}{'-' * (columns-4)} {Fore.CYAN}|")
def start_bot(names: list, messages: list, driver: any) -> None:
# Local variables
wait = WebDriverWait(driver, WEBDRIVER_WAIT_TIMEOUT)
# Logic/Actual Code
log("info", "bot starting...")
driver.maximize_window()
log("info", "Opening whatsapp...")
driver.get(URL)
log("success", "Successfully opened whatsapp!")
# @Wait for person to verify the link
log("info", "Awaiting manual authentication...")
wait.until(EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div/div/div[3]/header/div[1]/div/img")))
log("success", "Authentication successful!")
# Pause for page to load and syncing
log("info", "Waiting for synchronization and full page...")
time.sleep(15)
# Get the chat list container
log("info", "Getting chat list...")
chat_list_container = wait.until(EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div/div/div[3]/div/div[2]/div[2]/div/div")))
chat_list = chat_list_container.find_elements(by=By.XPATH, value="./child::*")
log("success", "Found chat list!")
# make all names lower case
names = [name.lower() for name in names]
log("info", "Iterating over list...")
for i, contact in enumerate(chat_list):
log("info", f" ITERATION#{i+1}", hierarchy_level=1)
contact_name = contact.find_element(By.CSS_SELECTOR, "div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > span").text
log(f"info", f"Name: {contact_name.title()}", hierarchy_level=2)
# if i >= 0:
if contact_name.lower() in names:
log("info", "Clicking on contact...", hierarchy_level=2)
contact.click()
log("info", "Clicking on text box", hierarchy_level=2)
text_box = wait.until(EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div/div/div[4]/div/footer/div[1]/div/span[2]/div/div[2]/div[1]/div/div[1]")))
text_box.click()
# Loop through messages list and send them one by one
log("info", "Sending messages", hierarchy_level=2)
for message in messages:
log(f"info", f"Writing: {message}", hierarchy_level=3)
text_box.send_keys(message)
# Wait for brief moment before sending to ensure full reliability
log(f"info", f"WAITING", hierarchy_level=4)
time.sleep(0.4)
log(f"info", f"Sending the message...", hierarchy_level=4)
# Get send button element
send_button = wait.until(EC.presence_of_element_located(("xpath", "/html/body/div[1]/div/div/div[4]/div/footer/div[1]/div/span[2]/div/div[2]/div[2]/button")))
wait.until(EC.element_to_be_clickable(send_button))
# send the message
send_button.click()
log("success", "Message sent successfully", hierarchy_level=4)
# Remove the current name from the list
names.remove(contact_name.lower())
# Delay for x seconds before moving on to next person
time.sleep(0.5)
# Check if there are still contacts in the list
if len(names) > 0:
log("error", f"need to send messages to: {names}")
log("info", "Using other method for remaining people...")
# Get the search box
log("info", "Getting search box...")
search_box = wait.until(EC.presence_of_element_located(
(By.XPATH, "/html/body/div[1]/div/div/div[3]/div/div[1]/div/div/div[2]/div/div[2]")))
log("success", "Successfully got search box!")
log('info', "Iterating over remaining contacts...")
# Loop through remaining contact names
names = [name.lower() for name in names]
for i, name in enumerate(names):
log("info", f"Remaining Contact#{i+1}: {name}", hierarchy_level=1)
# Clear search box text
log("info", "Clearing search text...", hierarchy_level=2)
# Click on search box three times to select all text
search_box.click()
search_box.clear()
log("success", "Search text clear!", hierarchy_level=2)
# Type the name in the search box
log("info", f"Typing '{name.title()}' in the search box...", hierarchy_level=2)
search_box.send_keys(name)
# Search
log("info", f"Searching...", hierarchy_level=2)
search_box.send_keys(Keys.ENTER)
# Pause for everything to load
log("info", "WAITING", hierarchy_level=2)
time.sleep(1)
log("success", "Search successful!", hierarchy_level=2)
# If no contact name appears, print error and go to next iteration
try:
if driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div[3]/div/div[2]/div[1]/div/span").text == "No chats, contacts or messages found":
log("error", f"Contact(Name: {name}) was not found!", hierarchy_level=2)
if not i == len(names) - 1:
log("info", "Skipping to next iteration!", hierarchy_level=2)
time.sleep(0.5)
# Skip to next iteration
continue
except Exception as e:
pass
# Get results
search_results_container = wait.until(
EC.presence_of_element_located((By.XPATH, '//*[@id="pane-side"]')))
search_results = search_results_container.find_elements(by=By.XPATH, value="./child::*")
print(f"SEARCH RESULTS: {search_results}\nLENGTH: {len(search_results)}")
# Pressing enter automatically selects first contact, so no need to reselect it
log("success", "Contact selected successfully!", hierarchy_level=3)
# Send messages to that contact
log("info", "Clicking on text box", hierarchy_level=3)
text_box = wait.until(EC.presence_of_element_located((By.XPATH,
"/html/body/div[1]/div/div/div[4]/div/footer/div[1]/div/span[2]/div/div[2]/div[1]/div/div[1]")))
text_box.click()
log("info", "Sending messages", hierarchy_level=3)
for message in messages:
log(f"info", f"Writing: {message}", hierarchy_level=4)
text_box.send_keys(message)
# Wait for brief moment before sending to ensure full reliability
log(f"info", f"WAITING", hierarchy_level=5)
time.sleep(0.4)
log(f"info", f"Sending the message...", hierarchy_level=5)
# Get send button element
send_button = wait.until(EC.presence_of_element_located(("xpath", "/html/body/div[1]/div/div/div[4]/div/footer/div[1]/div/span[2]/div/div[2]/div[2]/button")))
wait.until(EC.element_to_be_clickable(send_button))
# send the message
send_button.click()
log("success", "Message sent successfully", hierarchy_level=5)
# Sleep for brief moment
log("info", "WAITING", hierarchy_level=2)
time.sleep(0.7)
pretty_print(f"{Fore.YELLOW}Press {Fore.CYAN}ENTER to exit!", align="left", back_separator=False, front_separator=False)
pretty_print("")
def start_bot_https(names: list, messages: list) -> None:
print_title()
pretty_print(f"{Fore.YELLOW}To be developed ( issue#19 and issue#2 )", back_separator=False, front_separator=False)
pretty_print(f"{Fore.YELLOW}Press ENTER to return", align="left")
input()
def main() -> None:
# Global vars
global enable_logs
# Clearing the screen before running
clear_screen()
# Print title
print_title()
# Get required data
# Get names of contacts/groups to send the message to
names = pretty_input(f"{Fore.BLUE}Enter the contact/group names separated by a comma(,)")
messages = pretty_input(f"{Fore.BLUE}Enter the message(s) that you want to send separated by a comma(,)")
enable_logs = pretty_input(f"{Fore.BLUE}Enable logs to view progress of the bot? [ True/False ]").lower()
# Convert enable logs to boolean
if enable_logs.startswith("t") or enable_logs == "1":
enable_logs = True
elif enable_logs.startswith("f") or enable_logs == "0":
enable_logs = False
else:
enable_logs = True
# Ask if use http requests or selenium
method = pretty_input(f"{Fore.BLUE}What should the bot use? [ Selenium/HTTP Requests ]").lower()
if method.startswith("h"):
clear_screen()
start_bot_https(names, messages)
clear_screen()
return
# Convert names and messages to list if they are not singular
# Check if there are more names
if "," in names:
names = names.split(",")
# Check if there are more than one messages
if "," in messages:
messages = messages.split(",")
# Remove unnecessary spaces from names list and messages list
names = [name.strip() for name in names]
messages = [msg.strip() for msg in messages]
browser = pretty_input(f"{Fore.BLUE}Which browser to use?/What browser do you have installed? [ Chrome/FireFox ]").lower()
clear_screen()
# Initialize the driver
log("info", "Initializing web driver...")
log("info", "Installing the web driver...")
# Check what browser user wished and initialize driver accordingly
if browser.startswith("ch"):
try:
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
except Exception as e:
log("error", "Unable to automatically install chromedriver!\nTrying manual mode instead...")
try:
# Use chromedriver, assuming it is in same path
path = os.path.abspath("./chromedriver" if OS.lower().startswith("lin") else "chromedriver.exe")
service = webdriver.Chrome(executable_path=path)
driver = webdriver.Chrome(service=service)
except Exception as e:
log("error", "Unable to get chromedriver manually!")
log("info", "Quitting...")
log("error",e)
sys.exit()
elif browser.startswith("fir"):
try:
driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
except Exception as e:
log("error", "Unable to automatically install geckodriver!\nTrying manual mode instead...")
try:
# Use geckodriver, assuming it is in same path
path = os.path.abspath("./geckodriver" if OS.lower().startswith("lin") else "geckodriver.exe")
service = FirefoxService(executable_path=path)
driver = webdriver.Firefox(service=service)
except Exception as e:
log("error", "Unable to get geckodriver manually!")
log("info", "Quitting...")
sys.exit()
else:
log("error", "Browser is not compatible!!")
log("success", "Successfully initialized web driver!")
# Start the bot
start_bot(names, messages, driver)
def check_color_string_in_dict(string: str, dictionary: dict, pattern_look_len: int) -> (bool, int):
count = 0
for index, char in enumerate(string):
if char == "\x1b":
full_pattern = string[index: index+pattern_look_len]
if full_pattern in dictionary.values():
count += 1
if count == 0:
return False, count
else:
return True, count
def pretty_input(prompt: str):
if not prompt.strip() == "":
pretty_print(prompt, align="left", back_separator=False, front_separator=False)
user_input = input(f"{Fore.CYAN}| {APP_INPUT_SEPARATOR_COLOR}-> {APP_INPUT_COLOR}").lower()
separate_line()
return user_input
def pretty_print(text: str, align="center", blank_character=" ", back_separator=True, front_separator=True) -> None:
"""Print function, with alignment and aesthetics - Made by IamMU with 💗 for Whatsapp Bomber in Hacktoberfest"""
align = align.lower()
colored_text = text
for color in Fore.__dict__:
text = text.replace(Fore.__dict__[color], "")
uncolored_text = text
# Get updated terminal size
terminal_size_h = os.get_terminal_size().columns
# Lengths
colored_text_length = len(colored_text)
uncolored_text_length = len(uncolored_text)
# Buffers
uncolored_text_buffer = list()
colored_text_insertion_buffer = list()
finalized_text_buffer = list()
# Calculating buffers
available_char_space = terminal_size_h - 4
if len(uncolored_text) >= available_char_space:
# Variables for calculation
position_counter = 0
last_position = position_counter
current_text_buffer = str()
# Calculate uncolored buffer
for index, unc_char in enumerate(uncolored_text):
position_counter = (index + 1) - last_position
# Add the character to the current text buffer
current_text_buffer += unc_char
# Check if position counter is greater than available space
if position_counter >= available_char_space:
# Add the character in the current_text_buffer to the uncolored buffer
uncolored_text_buffer.append(current_text_buffer)
# Set last position to current
last_position = position_counter + last_position
# Reset the position counter
position_counter = 0
# Reset current text buffer
current_text_buffer = ""
# Check if position counter(+ last position to make it current) is last character
if position_counter + last_position >= uncolored_text_length:
# Add the character in the current_text_buffer to the uncolored buffer
uncolored_text_buffer.append(current_text_buffer)
# Set last position to 0 because end of loop
last_position = 0
# Reset the position counter
position_counter = 0
# Reset current text buffer
current_text_buffer = ""
color_code_chars_length = 5
without_color_index = 0
# Calculate color insertion buffer
for index, c_char in enumerate(colored_text):
if c_char == "\x1b":
if not without_color_index - color_code_chars_length <= 0:
without_color_index -= color_code_chars_length
colored_text_insertion_buffer.append(((without_color_index, without_color_index+color_code_chars_length), c_char + colored_text[index+1:index+color_code_chars_length]))
without_color_index += 1
continue
without_color_index += 1
else:
uncolored_text_buffer.append(uncolored_text)
colored_text_insertion_buffer.append(colored_text)
finalized_text_buffer.append(colored_text)
if len(uncolored_text) >= available_char_space:
last_color = ""
for unc_text in uncolored_text_buffer:
res = ""
skip_parent_iteration = False
last_index = 0
for index, char in enumerate(unc_text):
if len(colored_text_insertion_buffer) > 0:
for color_insertion in colored_text_insertion_buffer:
i = color_insertion[0][0]
v = color_insertion[1]
if index == i:
res += v + char
last_color = v
colored_text_insertion_buffer.remove(color_insertion)
skip_parent_iteration = True
if skip_parent_iteration:
skip_parent_iteration = False
continue
res += char
if not index == last_index:
res = last_color + res
last_index = index
finalized_text_buffer.append(res)
for ftext in finalized_text_buffer:
if len(ftext) > 5:
is_color, color_count = check_color_string_in_dict(ftext, Fore.__dict__, 5)
if is_color:
length_of_text = int(len(ftext) - (color_count * 5))
else:
length_of_text = len(ftext)
else:
length_of_text = len(ftext)
# Calculate the amount of space, taking alignment into consideration
if align == "center":
# Amount of space is the half of the screen width - the length of the side separators - the half of the text length
amount_of_space = int((terminal_size_h - 2)/2 - length_of_text/2)
# Make spacing variables
space_left = blank_character * amount_of_space
space_right = blank_character * amount_of_space
elif align == "right":
# Amount of space is the screen width - the side separator's length - the text length
amount_of_space = int((terminal_size_h - 2) - length_of_text)
space_left = blank_character * (amount_of_space - 1)
space_right = " "
elif align == "left":
# Amount of space is the screen width - the side separator's length - the text length
amount_of_space = int((terminal_size_h - 2) - length_of_text)
space_left = " "
space_right = blank_character * (amount_of_space - 1)
if len(space_left) + len(space_right) + length_of_text <= terminal_size_h:
if align == "center":
space_right = space_right + blank_character * ((terminal_size_h - 2) - (len(space_left) + len(space_right) + length_of_text))
elif align == "right":
space_left = space_left + blank_character * ((terminal_size_h - 2) - (len(space_left) + len(space_right) + length_of_text))
elif align == "left":
space_right = space_right + blank_character * ((terminal_size_h - 2) - (len(space_left) + len(space_right) + length_of_text))
result = f"{Fore.CYAN}|{Fore.RESET}" + space_left + ftext + space_right + f"{Fore.CYAN}|"
finalized_text_buffer[finalized_text_buffer.index(ftext)] = result
if back_separator:
separate_line()
# Print text in finalized text buffer
for msg in finalized_text_buffer:
print(msg)
if front_separator:
separate_line()
def print_title() -> None:
# Print version and logo/name
pretty_print(f"{Fore.GREEN}W H A T S {Fore.LIGHTGREEN_EX}A P P {Fore.LIGHTMAGENTA_EX}B {Fore.LIGHTYELLOW_EX}O M B {Fore.GREEN}E R", align="center", front_separator=False)
pretty_print(f"{APP_VERSION_COLOR}version {VERSION}", align="center", back_separator=False)
def customizations_menu() -> None:
clear_screen()
# Print title
print_title()
# TBD (ISSUE#18)
pretty_print(f"{Fore.RED}To be developed (issue#18)", back_separator=False)
pretty_print(f"{Fore.YELLOW}Press ENTER to return!", front_separator=False, back_separator=False)
pretty_input("")
clear_screen()
def credits_menu() -> None:
clear_screen()
contributors = ["IamMU", "pathikg", "rushabhgandhi13", "b-Istiak-s"]
# Print credits
pretty_print(f"{Fore.YELLOW}INFORMATION", align="center")
pretty_print(f"Whatsapp Bomber is an open-source project made to automate whatsapp messages so you can prioritize tasks, other than managing whatsapp groups.",
back_separator=False, align="center")
pretty_print(f"{Fore.YELLOW}AUTHOR/OWNER", align="center", back_separator=False)
pretty_print(f"Manan Pandya[ https://github.com/mrpandya ]", align="center", back_separator=False)
pretty_print(f"{Fore.YELLOW}CONTRIBUTORS", align="center", back_separator=False)
for contributor in contributors:
pretty_print(f"{contributor} [ https://github.com/{contributor} ]", align="center", back_separator=False, front_separator=False)
separate_line()
input(f"{Fore.CYAN}| {APP_INPUT_COLOR}Press ENTER to return")
def main_menu() -> None:
clear_screen()
user_input = str()
possible_quit_commands = ["exit", "quit", "q", "end", "4", "e"]
options = ["1", "2", "3", "4", "start bot", "customizations", "credits"]
error_messages = []
while not user_input in possible_quit_commands:
print_title()
# Print Main Menu Options
pretty_print(f"{MAIN_MENU_TITLE_COLOR}Main Menu", align="center", back_separator=False)
pretty_print(f"{MAIN_MENU_OPTIONS_NUMBER_COLOR}1) {MAIN_MENU_OPTIONS_TEXT_COLOR}Start Bot", align="center", back_separator=False, front_separator=False)
pretty_print(f"{MAIN_MENU_OPTIONS_NUMBER_COLOR}2) {MAIN_MENU_OPTIONS_TEXT_COLOR}Customizations/Settings", align="center", back_separator=False, front_separator=False)
pretty_print(f"{MAIN_MENU_OPTIONS_NUMBER_COLOR}3) {MAIN_MENU_OPTIONS_TEXT_COLOR}Credits", align="center", back_separator=False, front_separator=False)
pretty_print(f"{MAIN_MENU_OPTIONS_NUMBER_COLOR}4) {MAIN_MENU_OPTIONS_TEXT_COLOR}Exit", align="center", back_separator=False)
# Print Disclaimer
pretty_print(f"{MAIN_MENU_DISCLAIMER_WARNING_COLOR}DO NOT USE FOR SPAM OR ANY OTHER MALICIOUS USE", align="center", back_separator=False)
# Print all errors if any
lines_used = 15
if len(error_messages) > 0:
if len(error_messages) > TERMINAL_SIZE.lines - lines_used:
error_messages.pop(0)
for error in error_messages:
pretty_print("[ ERROR ] " + error, align="center", back_separator=False, front_separator=False)
separate_line()
# Print User Input Prompt
user_input = pretty_input("")
# TODO: Options
# TODO: Make pretty print print big text on different lines
if user_input in options:
if user_input.startswith("1") or user_input.startswith("s"):
main()
elif user_input.startswith("2") or user_input.startswith("cu"):
customizations_menu()
elif user_input.startswith("3") or user_input.startswith("cr"):
credits_menu()
else:
error_messages.append(f"{Fore.YELLOW}Please choose a correct option! {Fore.LIGHTYELLOW_EX}Your previous option '{user_input}' is not valid!")
# Clear the screen
clear_screen()
# Goodbye message
pretty_print(f"{MAIN_MENU_EXIT_MESSAGE_COLOR}Goodbye!")
#####################
# PROGRAM EXECUTION #
#####################
if __name__ == "__main__":
clear_screen()
main_menu()