forked from TotalAwesome/BotFarmFactory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfactory.py
74 lines (64 loc) · 1.95 KB
/
factory.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
"""
https://github.com/TotalAwesome/BotFarmFactory
https://t.me/CryptoAutoFarm
"""
from time import sleep
from random import random, shuffle
from initiator import Initiator
from accounts import TELEGRAM_ACCOUNTS
from bots.base.base import logging
from bots.base.utils import check_proxy
from config import MULTITHREAD
from utils import BOTS
if MULTITHREAD:
from threading import Thread
def make_account_farmers(account):
phone = account['phone']
if proxy := account.get('proxy'):
proxies = dict(http=proxy, https=proxy)
proxy = proxy if check_proxy(proxies=proxies) else None
try:
initiator = Initiator(phone)
except Exception as e:
logging.error(f'{phone} Error: {e}')
return []
farmers = []
for farmer_class in BOTS:
try:
farmer = farmer_class(initiator=initiator, proxy=proxy)
except Exception as e:
logging.error(f'{farmer_class.name} init error: {e}')
continue
if not farmer.is_alive:
continue
farmers.append(farmer)
initiator.disconnect()
sleep(random() * 10)
return farmers
def main(farmers):
while True:
shuffle(farmers)
for farmer in farmers:
farmer.proceed_farming()
sleep(1 + random())
sleep(1)
def farm_in_thread(phone):
import asyncio
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
main(make_account_farmers(phone))
if MULTITHREAD:
for account in TELEGRAM_ACCOUNTS:
Thread(target=farm_in_thread, args=(account,)).start()
while True:
input()
else:
farmers = []
for account in TELEGRAM_ACCOUNTS:
farmers += make_account_farmers(account)
print('')
farmer_names = ", ".join(set([farmer.name.lower() for farmer in farmers]))
logging.info("Найдены фармеры: {farmer_names}".format(farmer_names=farmer_names))
if not farmers:
exit()
main(farmers)