-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.py
208 lines (183 loc) · 13.7 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
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
import os
import asyncio
import tzlocal
from bot import reload_page, connect_wallet, login_metamask, treasure_hunt_game, new_map, skip_error_on_game, refresh_hereoes_positions, send_heroes_to_work, first_start, SetTrigger, how_many_coins
from controllers import get_browser, countdown_timer, setup_logger, initialize_pyautogui, read_configurations, delete_log_files, delete_folders, create_bat_file
from pywinauto import Desktop
from itertools import cycle
from apscheduler.schedulers.background import BackgroundScheduler
try:
streamConfig = read_configurations()
refresh_heroes_time = streamConfig['heroes_options']['refresh_heroes_time']
refresh_heroes_only = streamConfig['heroes_options']['refresh_heroes_only']
work_heroes_time = streamConfig['heroes_options']['work_heroes_time']
refresh_browser_time = streamConfig['bot_options']['refresh_browser_time']
enable_multiaccount = streamConfig['bot_options']['enable_multiaccount']
chest_screenshot_time = streamConfig['heroes_options']['chest_screenshot_time']
except FileNotFoundError:
print('Error: config.yaml file not found, make sure config.yaml are placed in the folder..')
exit()
async def main():
logger = setup_logger(telegram_integration=True)
# Init message
print('\nPress Ctrl-C to quit at anytime!\n' )
hello_world = """
#******************************* BombCrypto Bot *********************************#
#────────────────────────────────────────────────────────────────────────────────#
#─────██████████████───██████████████─██████──────────██████─██████████████──────#
#─────██░░░░░░░░░░██───██░░░░░░░░░░██─██░░███────────███░░██─██░░░░░░░░░░██──────#
#─────██░░██████░░██───██░░██████░░██─██░░░███──────███░░░██─██░░██████░░██──────#
#─────██░░██──██░░██───██░░██──██░░██─██░░░░███────███░░░░██─██░░██──██░░██──────#
#─────██░░██████░░████─██░░██──██░░██─██░░░░░░██──███░░░░░██─██░░██████░░████────#
#─────██░░░░░░░░░░░░██─██░░██──██░░██─██░░░░██████████░░░░██─██░░░░░░░░░░░░██────#
#─────██░░████████░░██─██░░██──██░░██─██░░░░██─████─██░░░░██─██░░████████░░██────#
#─────██░░██────██░░██─██░░██──██░░██─██░░░░██──██──██░░░░██─██░░██────██░░██────#
#─────██░░████████░░██─██░░██████░░██─██░░░░██──────██░░░░██─██░░████████░░██────#
#─────██░░░░░░░░░░░░██─██░░░░░░░░░░██─██░░░░██──────██░░░░██─██░░░░░░░░░░░░██────#
#─────████████████████─██████████████─████████──────████████─████████████████────#
#────────────────────────────────────────────────────────────────────────────────#
#********************************************************************************#
#***************** Please donate to help improve the hard work ♥ ****************#
#********************************************************************************#
#**** BUSD/BCOIN/ETH/BNB (BEP20): 0xf1e43519fca44d9308f889baf99531ed0de903fc ****#
#**** PayPal: https://www.paypal.com/donate/?hosted_button_id=82CABN6CYVG6U *****#
#************* Nubank: https://nubank.com.br/pagar/1jxcl/z5fyuL6S28 *************#
#****************** Pix: 42a762ed-e6ec-4059-a88e-f168b9fbc63f *******************#
#********************************************************************************#
"""
print(hello_world)
# Initialize pyautogui library
await asyncio.create_task(initialize_pyautogui())
# Delete old log files
await asyncio.create_task(delete_log_files())
# Delete old folders
await asyncio.create_task(delete_folders())
# Creat bat file
await asyncio.create_task(create_bat_file())
# Countdown timer before start the bot
await asyncio.create_task(countdown_timer())
logger.info('------------------- New Execution ----------------\n')
logger.info('Donate on BUSD/BCOIN/ETH/BNB (BEP20): 0xf1e43519fca44d9308f889baf99531ed0de903fc')
logger.info('Donate on PayPal: https://www.paypal.com/donate/?hosted_button_id=82CABN6CYVG6U')
logger.info('Donate on Nubank: https://nubank.com.br/pagar/1jxcl/z5fyuL6S28')
logger.info('Donate on Pix: 42a762ed-e6ec-4059-a88e-f168b9fbc63f')
logger.info('Starting Bot..... Bot started!')
if refresh_heroes_only != False:
logger.info('The "refresh heroes only" option is enable, so only the refresh will work on the bot. If you want bot working the whole process, close the bot and change the option to False!')
if refresh_heroes_time == work_heroes_time:
logger.critical('You should set a different time for "refresh_heroes_time" and also send them to work from "work_heroes_time". Otherwise these steps might not start correctly.')
# Create a scheduler for certain functions
scheduler = BackgroundScheduler(timezone=str(tzlocal.get_localzone()))
trigger = SetTrigger()
if (refresh_heroes_time*60) > 59:
logger.info('Scheduling the refresh heroes positions every %s minute(s)!' % (refresh_heroes_time))
# - Do a full review on games
scheduler.add_job(trigger.UpdateSetRefresh, 'interval', minutes=refresh_heroes_time, id='1', name='refresh_hereoes_positions', misfire_grace_time=180)
if chest_screenshot_time > 4:
logger.info('Scheduling to take screenshot from chest every %s minute(s)!' % (chest_screenshot_time))
# - Do a full review on games
scheduler.add_job(trigger.UpdateSetCoin, 'interval', minutes=chest_screenshot_time, id='4', name='chest_screenshot_time', misfire_grace_time=180)
if refresh_heroes_only != True:
if (work_heroes_time*60) > 59:
logger.info('Scheduling the time for heroes to work every %s minute(s)!' % (work_heroes_time))
# - Send heroes to work
scheduler.add_job(trigger.UpdateSetWork, 'interval', minutes=work_heroes_time, id='2', name='send_heroes_to_work', misfire_grace_time=300)
if (refresh_browser_time*60) > 59:
logger.info('Scheduling the time for refreshing the browser every %s minute(s)!' % (refresh_browser_time))
# - Do a full review on games
scheduler.add_job(trigger.UpdateSetReload, 'interval', minutes=refresh_browser_time, id='3', name='refresh_browser_time', misfire_grace_time=900)
if len(scheduler.get_jobs()) > 0:
scheduler.start()
applications, website_browser = get_browser()
logger.info('Number of accounts that the bot will run: %s' % (len(applications)))
if 'Bombcrypto' not in website_browser:
logger.error('Bombcrypto website not open yet, please open the browser before starting this bot! Exiting bot...')
os._exit(0)
else:
if len(applications) > 0:
# Iterate through applications *once*, starting the app and creating the related bot name for future use.
for app in applications:
if enable_multiaccount != False:
print('Going to bot: ' + str(app[1]))
browser = Desktop(backend="uia").windows(title=app[0])[0]
browser.set_focus()
app.append(browser)
await asyncio.create_task(first_start(app_name=app[1]))
bot_executions_refresh = []
bot_executions_work = []
bot_executions_reload = []
bot_executions_coin = []
# Cycle through the bots in one loop rather than restarting the loop in an infinite loop
for app in cycle(applications):
if enable_multiaccount != False and refresh_heroes_only != True:
print('Going to bot: ' + str(app[1]))
app[2].set_focus()
if refresh_heroes_only != False:
if trigger.set_refresh != False:
if enable_multiaccount != False:
print('Going to bot: ' + str(app[1]))
app[2].set_focus()
bot_executions_refresh.append(app[1])
await asyncio.create_task(refresh_hereoes_positions(app_name=app[1]))
if (len(bot_executions_refresh) == len(applications)) and trigger.set_refresh != False:
bot_executions_refresh.clear()
trigger.set_refresh = False
if refresh_heroes_only != True:
# Steps of this bot:
# - Connect Wallet on BomberCypto game
await asyncio.create_task(connect_wallet(app_name=app[1]))
# - Login Metamask
await asyncio.create_task(login_metamask(app_name=app[1]))
# - Treasure Hunt game mode
await asyncio.create_task(treasure_hunt_game(refresh_only=True, app_name=app[1]))
# - New map feature
await asyncio.create_task(new_map(app_name=app[1]))
# - Check for errors on game
await asyncio.create_task(skip_error_on_game(app_name=app[1]))
# - Time to call some functions
if trigger.set_refresh != False:
if app[1] not in bot_executions_refresh:
bot_executions_refresh.append(app[1])
await asyncio.create_task(refresh_hereoes_positions(app_name=app[1]))
if trigger.set_work != False:
if app[1] not in bot_executions_work:
bot_executions_work.append(app[1])
await asyncio.create_task(send_heroes_to_work(app_name=app[1]))
if trigger.set_reload != False:
if app[1] not in bot_executions_reload:
bot_executions_reload.append(app[1])
await asyncio.create_task(reload_page(app_name=app[1]))
if trigger.set_coin != False:
if app[1] not in bot_executions_coin:
bot_executions_coin.append(app[1])
await asyncio.create_task(how_many_coins(app_name=app[1]))
# - Reset trigger to call functions from schedule
if (len(bot_executions_refresh) == len(applications)) and trigger.set_refresh != False:
bot_executions_refresh.clear()
trigger.set_refresh = False
if (len(bot_executions_work) == len(applications)) and trigger.set_work != False:
bot_executions_work.clear()
trigger.set_work = False
if (len(bot_executions_coin) == len(applications)) and trigger.set_coin != False:
bot_executions_coin.clear()
trigger.set_coin = False
if (len(bot_executions_reload) == len(applications)) and trigger.set_reload != False:
bot_executions_reload.clear()
bot_executions_coin.clear()
bot_executions_work.clear()
bot_executions_refresh.clear()
trigger.set_reload = False
trigger.set_coin = False
trigger.set_work = False
trigger.set_refresh = False
else:
logger.error('No account/profile found in the config.yaml file or profile do not match with profile opened, please check and restart the bot. Exiting bot...')
os._exit(0)
if __name__ == "__main__":
try:
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()
except Exception as e:
print("Exception: " + str(e))
exit()