forked from MsLolita/grass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
138 lines (104 loc) · 4.03 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
import asyncio
import ctypes
import random
import sys
import traceback
from art import text2art
from termcolor import colored, cprint
from better_proxy import Proxy
from core import Grass
from core.autoreger import AutoReger
from core.utils import logger, file_to_list
from core.utils.accounts_db import AccountsDB
from core.utils.exception import LoginException, NoProxiesException
from core.utils.generate.person import Person
from data.config import ACCOUNTS_FILE_PATH, PROXIES_FILE_PATH, REGISTER_ACCOUNT_ONLY, THREADS, REGISTER_DELAY, \
CLAIM_REWARDS_ONLY, APPROVE_EMAIL_ONLY
def bot_info(name: str = ""):
cprint(text2art(name), 'green')
if sys.platform == 'win32':
ctypes.windll.kernel32.SetConsoleTitleW(f"{name}")
print(
f"{colored('EnJoYeR <crypto/> moves:', color='light_yellow')} "
f"{colored('https://t.me/+tdC-PXRzhnczNDli', color='light_green')}"
)
print(
f"{colored('Donate here:', color='light_yellow')} "
f"{colored('0x000007c73a94f8582ef95396918dcd04f806cdd8', color='light_green')}"
)
async def worker_task(_id, account: str, proxy: str = None, db: AccountsDB = None):
consumables = account.split(":")[:2]
if len(consumables) == 1:
email = consumables[0]
password = Person().random_string(8)
else:
email, password = consumables
grass = None
try:
grass = Grass(_id, email, password, proxy, db)
if REGISTER_ACCOUNT_ONLY:
await asyncio.sleep(random.uniform(*REGISTER_DELAY))
logger.info(f"Starting №{_id} | {email} | {password} | {proxy}")
await grass.create_account()
elif APPROVE_EMAIL_ONLY:
await asyncio.sleep(random.uniform(*REGISTER_DELAY))
logger.info(f"Starting №{_id} | {email} | {password} | {proxy}")
await grass.confirm_email()
elif CLAIM_REWARDS_ONLY:
await asyncio.sleep(random.uniform(*REGISTER_DELAY))
logger.info(f"Starting №{_id} | {email} | {password} | {proxy}")
await grass.claim_rewards()
else:
await asyncio.sleep(random.uniform(1, 2) * _id)
logger.info(f"Starting №{_id} | {email} | {password} | {proxy}")
await grass.start()
return True
# except LoginException as e:
# logger.warning(f"LoginException | {_id} | {e}")
# except NoProxiesException as e:
# logger.warning(e)
except Exception as e:
logger.error(f"{_id} | not handled exception | error: {e} {traceback.format_exc()}")
finally:
if grass:
await grass.session.close()
async def main():
accounts = file_to_list(ACCOUNTS_FILE_PATH)
proxies = [Proxy.from_str(proxy).as_url for proxy in file_to_list(PROXIES_FILE_PATH)]
db = AccountsDB('data/proxies_stats.db')
await db.connect()
for i, account in enumerate(accounts):
account = account.split(":")[0]
proxy = proxies[i] if len(proxies) > i else None
if await db.proxies_exist(proxy) or not proxy:
continue
await db.add_account(account, proxy)
await db.delete_all_from_extra_proxies()
await db.push_extra_proxies(proxies[len(accounts):])
autoreger = AutoReger.get_accounts(
(ACCOUNTS_FILE_PATH, PROXIES_FILE_PATH),
with_id=True,
static_extra=(db, )
)
threads = THREADS
if REGISTER_ACCOUNT_ONLY:
msg = "__REGISTER__ MODE"
elif APPROVE_EMAIL_ONLY:
msg = "__APPROVE__ MODE"
elif CLAIM_REWARDS_ONLY:
msg = "__CLAIM__ MODE"
else:
msg = "__MINING__ MODE"
threads = len(autoreger.accounts)
logger.info(msg)
await autoreger.start(worker_task, threads)
await db.close_connection()
if __name__ == "__main__":
bot_info("GRASS_AUTO")
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main())
else:
asyncio.run(main())