Merge pull request #56 from TheGhostRoot/main

Did little improvments of preforments
This commit is contained in:
mouadessalim 2023-02-02 22:41:03 +01:00 committed by GitHub
commit ced938ba5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@ -30,7 +30,7 @@ from pystyle import Box, Center, Colorate, Colors, System, Write
from selenium import webdriver from selenium import webdriver
from selenium.common.exceptions import WebDriverException from selenium.common.exceptions import WebDriverException
from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.service import Service
from constants import BANNER, NO, PYSTRAY_IMG, YES, SLEEP_TIME from constants import BANNER, PYSTRAY_IMG, SLEEP_TIME
from discord_token import QRGrabber, TokenInfo from discord_token import QRGrabber, TokenInfo
from exceptions import InvalidToken, QRCodeNotFound, WebhookSendFailure from exceptions import InvalidToken, QRCodeNotFound, WebhookSendFailure
from queue import Queue from queue import Queue
@ -124,10 +124,10 @@ def main(webhook_url: str) -> None:
thread_timer_killer.join(120) thread_timer_killer.join(120)
if thread_timer_killer.is_alive(): if thread_timer_killer.is_alive():
e.set() e.set()
while True: while thread_timer_killer.is_alive():
if not thread_timer_killer.is_alive(): continue
main.driver.service.process.send_signal(SIGTERM) main.driver.service.process.send_signal(SIGTERM)
break
try: try:
os.remove('discord_gift.png') os.remove('discord_gift.png')
except BaseException: except BaseException:
@ -186,8 +186,8 @@ if __name__ == "__main__":
confir = Write.Input( confir = Write.Input(
"[*] Do you want to use a Discord Webhook URL ? [y/n] -> ", "[*] Do you want to use a Discord Webhook URL ? [y/n] -> ",
Colors.green_to_cyan, Colors.green_to_cyan,
interval=0.01) interval=0.01).lower()
if (confir == YES) or (confir == YES.upper()): if confir == "yes" or confir == "y":
th_main = Thread( th_main = Thread(
target=main, target=main,
args=( args=(
@ -195,7 +195,7 @@ if __name__ == "__main__":
Colors.green_to_cyan, Colors.green_to_cyan,
interval=0.01), interval=0.01),
)) ))
elif (confir == NO) or (confir == NO.upper()): elif confir == "no" or confir == "n":
th_main = Thread(target=main, args=(None,)) th_main = Thread(target=main, args=(None,))
else: else:
raise SystemExit(Write.Print( raise SystemExit(Write.Print(
@ -203,8 +203,7 @@ if __name__ == "__main__":
Colors.yellow_to_green)) Colors.yellow_to_green))
Thread(target=pystray_icon).start() Thread(target=pystray_icon).start()
th_main.start() th_main.start()
while True: while th_main.is_alive():
if not th_main.is_alive():
pystray_icon.icon.stop()
break
time.sleep(SLEEP_TIME) time.sleep(SLEEP_TIME)
pystray_icon.icon.stop()