-
Notifications
You must be signed in to change notification settings - Fork 48
/
main.py
94 lines (76 loc) · 3.48 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
import sys
import traceback
from time import sleep
import requests
from packaging import version
from module.bombScreen import BombScreen, BombScreenEnum
from module.config import Config
from module.image import Image
from module.logger import logger, reset_log_file
from module.manager import create_bombcrypto_managers
from module.telegram import TelegramBot
__version__ = "0.0.5"
def main(config_file):
try:
# Load configs
Config.load_config(config_file)
Image.load_targets()
TelegramBot.load_config()
if Config.get("generals", "reset_log_file"):
reset_log_file()
r = requests.get(
"https://api.github.com/gists/715eabaa3bca5ca70709a6397b806e86"
)
if r.ok:
data = r.json()
start_message = data["files"]["start_message"]["content"]
logger(start_message, color="cyan", datetime=False)
last_version = data["files"]["version"]["content"].strip()
version_installed = version.parse(__version__)
logger(f"-> Current version: {version_installed}", color="cyan", datetime=False)
if version.parse(last_version) > version.parse(__version__):
logger("-----------------------------------------------", color="green", datetime=False)
logger(f"New version available: {last_version}.", color="green", datetime=False)
update_message = data["files"]["update_message"]["content"]
logger(update_message, color="green", datetime=False)
logger("-----------------------------------------------", color="green", datetime=False)
else:
logger("Unable to check for updates.")
bomb_crypto_managers = create_bombcrypto_managers()
logger(f"{len(bomb_crypto_managers)} Bombcrypto window (s) found")
bomb_browser_count = 1
show_initial_screen_message = True
while True:
try:
for manager in bomb_crypto_managers:
current_screen = BombScreen.get_current_screen()
if show_initial_screen_message:
logger(f"💫 Bombcrypto window[{bomb_browser_count}] inicializado em: {BombScreenEnum(current_screen).name}")
with manager:
manager.do_what_needs_to_be_done(current_screen)
if bomb_browser_count == len(bomb_crypto_managers):
bomb_browser_count = 1
show_initial_screen_message = False
else:
bomb_browser_count += 1
except Exception as e:
logger(
traceback.format_exc(),
color="red",
force_log_file=True,
terminal=False,
)
logger(
f"😬 Ohh no! A error has occurred in the last action.\n{e}\n Check the log file for more details.",
color="yellow",
)
sleep(5)
except Exception:
logger(traceback.format_exc(), color="red", force_log_file=True, terminal=False)
logger("😬 Ohh no! We couldn't start the bot.", color="red")
if __name__ == "__main__":
config_path = "config.yaml"
if len(sys.argv) > 1:
config_file = sys.argv[1]
config_path = f"config_profiles/{config_file}.yaml"
main(config_path)