-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
main.py
114 lines (93 loc) · 5.44 KB
/
main.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
import Utils.config_loader as cfg_loader
from first_setup import first_setup
from colorama import Fore, Style
import Utils.logger
from Utils.logger import LOGGER_CONFIG
import logging.config
import colorama
import sys
import os
from vertex import Vertex
import Utils.exceptions as excs
from locales.localizer import Localizer
logo = f"""
{Fore.CYAN}{Style.BRIGHT}███████╗██╗ ██╗███╗ ██╗██████╗ █████╗ ██╗ ██╗
██╔════╝██║ ██║████╗ ██║██╔══██╗██╔══██╗╚██╗ ██╔╝
█████╗ ██║ ██║██╔██╗ ██║██████╔╝███████║ ╚████╔╝
██╔══╝ ██║ ██║██║╚██╗██║██╔═══╝ ██╔══██║ ╚██╔╝
██║ ╚██████╔╝██║ ╚████║██║ ██║ ██║ ██║
╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝ ╚═╝{Style.RESET_ALL}
{Fore.RED}{Style.BRIGHT}██╗ ██╗███████╗██████╗ ████████╗███████╗██╗ ██╗
██║ ██║██╔════╝██╔══██╗╚══██╔══╝██╔════╝╚██╗██╔╝
██║ ██║█████╗ ██████╔╝ ██║ █████╗ ╚███╔╝
╚██╗ ██╔╝██╔══╝ ██╔══██╗ ██║ ██╔══╝ ██╔██╗
╚████╔╝ ███████╗██║ ██║ ██║ ███████╗██╔╝ ██╗
╚═══╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝{Style.RESET_ALL}
"""
VERSION = "0.1.6"
if getattr(sys, 'frozen', False):
os.chdir(os.path.dirname(sys.executable))
else:
os.chdir(os.path.dirname(__file__))
folders = ["configs", "logs", "storage", "storage/cache", "storage/products"]
for i in folders:
if not os.path.exists(i):
os.makedirs(i)
files = ["configs/auto_delivery.cfg", "configs/auto_response.cfg"]
for i in files:
if not os.path.exists(i):
with open(i, "w", encoding="utf-8") as f:
...
# UPDATE 0.0.9
if os.path.exists("storage/cache/block_list.json"):
os.rename("storage/cache/block_list.json", "storage/cache/blacklist.json")
# UPDATE 0.0.9
colorama.init()
logging.config.dictConfig(LOGGER_CONFIG)
logging.raiseExceptions = False
logger = logging.getLogger("main")
logger.debug("------------------------------------------------------------------")
print(logo)
print(f"{Fore.RED}{Style.BRIGHT}v{VERSION}{Style.RESET_ALL}\n")
print(f"{Fore.MAGENTA}{Style.BRIGHT}By {Fore.BLUE}{Style.BRIGHT}NightStranger, Lemarty{Style.RESET_ALL}")
print(f"{Fore.MAGENTA}{Style.BRIGHT} * GitHub: {Fore.BLUE}{Style.BRIGHT}https://github.com/NightStrang6r/FunPayVertex{Style.RESET_ALL}")
print(f"{Fore.MAGENTA}{Style.BRIGHT} * Telegram: {Fore.BLUE}{Style.BRIGHT}https://t.me/funpayplace")
print(f"{Fore.MAGENTA}{Style.BRIGHT} * Discord: {Fore.BLUE}{Style.BRIGHT}https://dsc.gg/funpay\n")
if not os.path.exists("configs/_main.cfg"):
first_setup()
sys.exit()
try:
logger.info("$MAGENTAЗагружаю конфиг _main.cfg...")
MAIN_CFG = cfg_loader.load_main_config("configs/_main.cfg")
localizer = Localizer(MAIN_CFG["Other"]["language"])
_ = localizer.translate
logger.info("$MAGENTAЗагружаю конфиг auto_response.cfg...")
AR_CFG = cfg_loader.load_auto_response_config("configs/auto_response.cfg")
RAW_AR_CFG = cfg_loader.load_raw_auto_response_config("configs/auto_response.cfg")
logger.info("$MAGENTAЗагружаю конфиг auto_delivery.cfg...")
AD_CFG = cfg_loader.load_auto_delivery_config("configs/auto_delivery.cfg")
except excs.ConfigParseError as e:
logger.error(e)
logger.error("Завершаю программу...")
sys.exit()
except UnicodeDecodeError:
logger.error("Произошла ошибка при расшифровке UTF-8. Убедитесь, что кодировка файла = UTF-8, "
"а формат конца строк = LF.")
logger.error("Завершаю программу...")
sys.exit()
except:
logger.critical("Произошла непредвиденная ошибка.")
logger.debug("TRACEBACK", exc_info=True)
logger.error("Завершаю программу...")
sys.exit()
localizer = Localizer(MAIN_CFG["Other"]["language"])
try:
Vertex(MAIN_CFG, AD_CFG, AR_CFG, RAW_AR_CFG, VERSION).init().run()
except KeyboardInterrupt:
logger.info("Завершаю программу...")
sys.exit()
except:
logger.critical("При работе Вертекса произошла необработанная ошибка.")
logger.debug("TRACEBACK", exc_info=True)
logger.critical("Завершаю программу...")
sys.exit()