-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
96 lines (81 loc) · 3.32 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
from typing import Awaitable
import random
from asyncio import (
create_task,
gather,
sleep,
run
)
from loguru import logger
from tqdm import tqdm
from config import *
from src.utils.mappings import module_handlers
from src.utils.helper import (
private_keys,
active_module,
)
async def main() -> None:
tasks = []
if RUN_FOREVER:
while True:
for private_key in private_keys:
if RANDOMIZE is False:
for pattern in active_module:
try:
task = create_task(module_handlers[pattern](private_key))
tasks.append(task)
time_to_sleep = random.randint(MIN_PAUSE, MAX_PAUSE)
logger.info(f'Sleeping {time_to_sleep} seconds...')
await task
await sleep(time_to_sleep)
except Exception as ex:
logger.error(f'Something went wrong {ex}')
continue
else:
try:
random_index = random.randint(0, len(active_module) - 1)
random_element = active_module[random_index]
task = create_task(module_handlers[random_element](private_key))
tasks.append(task)
time_to_sleep = random.randint(MIN_PAUSE, MAX_PAUSE)
logger.info(f'Sleeping {time_to_sleep} seconds...')
await task
await sleep(time_to_sleep)
except Exception as ex:
logger.error(f'Something went wrong {ex}')
pass
else:
for private_key in private_keys:
if RANDOMIZE is False:
for pattern in active_module:
try:
task = create_task(module_handlers[pattern](private_key))
tasks.append(task)
time_to_sleep = random.randint(MIN_PAUSE, MAX_PAUSE)
logger.info(f'Sleeping {time_to_sleep} seconds...')
await task
await sleep(time_to_sleep)
except Exception as ex:
logger.error(f'Something went wrong {ex}')
continue
else:
random.shuffle(active_module)
for pattern in active_module:
try:
task = create_task(module_handlers[pattern](private_key))
tasks.append(task)
time_to_sleep = random.randint(MIN_PAUSE, MAX_PAUSE)
logger.info(f'Sleeping {time_to_sleep} seconds...')
await task
await sleep(time_to_sleep)
except Exception as ex:
logger.error(f'Something went wrong {ex}')
continue
await gather(*tasks)
def start_event_loop(awaitable: Awaitable[object]) -> None:
run(awaitable)
if __name__ == '__main__':
with tqdm(total=len(private_keys)) as pbar:
async def tracked_main():
await main()
start_event_loop(tracked_main())