forked from SteveHuiz/vk-slaves-python-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
452 lines (294 loc) · 16.4 KB
/
run.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
import time
import datetime
import random
import requests # pip install requests
import logging
from threading import Thread
from module import Slaves # module.py
from config import settings # config.py
token = settings['info']['TOKEN']
local_id = settings['info']['ID']
debug = settings['info']['DEBUG']
client = Slaves(token)
from api import * # api.py
balance = 0
# //////////////////////LOG_SAVING//////////////////////////////////////////////
logging.basicConfig(filename=f'{str(settings["info"]["LOG_NAME"])}.log',filemode="w", level=logging.INFO) # Создаем Logger
def print_log(printbl):
if settings['info']['SAVE_LOG']:
logging.info(str(printbl))
print(str(printbl))
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# processing slaves functions //////////////////////////////////////////////////
def get_slaves_to_steal(slaves_list):
slaves = []
min_price = settings['steal_top']['MIN_PRICE']
max_price = settings['steal_top']['MAX_PRICE']
current_time = int(time.time()) # текущее unix-время
for slave in slaves_list['slaves']: # Получаем каждого раба в словаре
if slave['fetter_to'] < current_time: # проверяем время цепей раба
if slave['price'] <= max_price and slave['price'] >= min_price: # если цена подходит под условие
slaves.append(slave['id']) # добавляем раба в наш список
return slaves
def get_slaves_to_steal_target(slaves_list):
slaves = []
min_price = settings['steal_target']['MIN_PRICE']
max_price = settings['steal_target']['MAX_PRICE']
current_time = int(time.time()) # текущее unix-время
for slave in slaves_list['slaves']: # Получаем каждого раба в словаре
if slave['fetter_to'] < current_time: # проверяем время цепей раба
if slave['price'] <= max_price and slave['price'] >= min_price: # если цена подходит под условие
slaves.append(slave['id']) # добавляем раба в наш список
return slaves
def get_slaves_to_job(slaves_list):
job_slaves = []
for slave in slaves_list['slaves']: # Получаем каждого раба в словаре
if slave['job']['name'] == '': # если безработен
job_slaves.append(slave['id']) # добавляем раба в безработных
return job_slaves
def get_slaves_to_abuse(slaves_list):
abuse_slaves = []
for slave in slaves_list['slaves']: # Получаем каждого раба в словаре
if (slave['sale_price'] < 19500):
abuse_slaves.append(slave['id']) # добавляем раба в безработных
return abuse_slaves
def get_slaves_to_fetter(slaves_list):
slaves = {}
current_time = int(time.time()) # текущее unix-время
for slave in slaves_list['slaves']: # Получаем каждого раба в словаре
if (slave['profit_per_min'] * 120) >= slave['fetter_price']: # мы не уйдём в минус
if slave['fetter_to'] < current_time: # проверяем время цепей раба
if (slave['profit_per_min'] >= 1000 or (not settings['fet_slaves']['MAX_PROFIT'])):
slaves[slave['id']] = 1 - slave['profit_per_min'] / (slave['fetter_price'] + 1) # добавляем раба в наш словарь (по формуле выгодности)
# сортируем рабов по цене
{k: v for k, v in sorted(slaves.items(), key=lambda item: item[1])}
# возвращаем айди рабов
return list(slaves.keys())
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# main functions to be used ////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# Обновление баланса для проверки
# Вывод основной информации
# Автоматическое включение
def update_me():
global balance
i = 0
while True:
try:
me = get_user(local_id)
balance = me['balance']
slaves = me['slaves_count']
rating = me['rating_position']
profit = me['slaves_profit_per_min']
if (i == 3):
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][INFO] > {balance}р | {profit}р/мин | {slaves} рабов | {rating} место')
i = 0
time.sleep(5 + (random.random() * random.randrange(-1,1)))
i += 1
except:
time.sleep(15)
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# Автоматическая выдача работы рабам
# config.py - job_slaves
# список работы настраивается там же
def job_niggers():
while True:
slaves_list = do_start()
slaves_to_job = get_slaves_to_job(slaves_list)
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][JOB] > Найдно {len(slaves_to_job)} безработных рабов')
random.shuffle(slaves_to_job)
for slave in slaves_to_job:
make_job(slave)
if (debug):
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][DEBUG] >>> выдал работу {slave}')
time.sleep(random.randrange(0, 3) + random.random() * 2.5)
else:
time.sleep(random.randrange(12, 23))
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# Автоматическая выдача цепей
# config.py - fet_slaves
def fet_niggers():
while True:
slaves_list = do_start()
slaves_to_fetter = get_slaves_to_fetter(slaves_list)
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][FET] > Найдено {len(slaves_to_fetter)} рабов без цепей')
random.shuffle(slaves_to_fetter)
# кидаем цепи на рабов
for slave in slaves_to_fetter:
fetter(slave)
if (debug):
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][DEBUG] >>> кинул цепи на {slave}')
# обход блокировки
time.sleep((random.randrange(0, 2) + random.randrange(0, 2)) + min(0.9, 145 / len(slaves_to_fetter)))
time.sleep(random.randrange(0, 1))
else:
time.sleep(random.randrange(11, 18))
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# Таргетированная кража рабов
# config.py - steal_target
# возможна настройка по ID
def steal_niggers():
while True:
targets = settings['steal_target']['TARGETS']
random.shuffle(targets)
for target in targets:
info = get_user(target)
if info['balance'] >= 2147000000: continue
targets_slaves = get_slaves(target)
slaves_to_steal = get_slaves_to_steal_target(targets_slaves)
random.shuffle(slaves_to_steal)
if len(slaves_to_steal) > 0:
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][TS] > Найдено {len(slaves_to_steal)} раба(ов) для кражи ({target})')
for slave in slaves_to_steal:
buy(slave)
time.sleep(random.randrange(2, 4))
if (settings['steal_target']['AUTO_FET']):
fetter(slave)
time.sleep(random.randrange(2, 3))
if (debug):
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][DEBUG] >>> украл {slave} у {target}')
make_job(slave)
# обход блокировки
time.sleep(random.randrange(1, 3) + min(0.9, 155 / len(slaves_to_steal)))
time.sleep(random.random() * 2.5)
time.sleep(random.randrange(3, 5))
time.sleep(random.randrange(settings['steal_target']['PAUSE'], (settings['steal_target']['PAUSE'] + 5)))
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# Абуз рабов для получения большего профита
# Продаёт - Покупает
# Возможна настройка цепей после абуза
# config.py - abuse_slaves
def abuse_niggers():
while True:
global balance
me = get_user(local_id)
balance = me['balance']
if (balance >= settings['abuse_slaves']['MIN_BALANCE']):
if (balance >= 2147000000):
print_log('[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][ABS] > Максимальный баланс!')
time.sleep(20)
continue
slaves_list = do_start()
slaves_to_abuse = get_slaves_to_abuse(slaves_list)
random.shuffle(slaves_to_abuse)
for slave in slaves_to_abuse:
if (balance < settings['abuse_slaves']['MIN_BALANCE']):
break
id_used = False
s_price = (get_user(slave))['sale_price']
while s_price < settings['abuse_slaves']['LIMIT']:
id_used = True
sale(slave) # продаём
time.sleep(random.random() * 2 + random.randrange(0, 2))
buy(slave)
time.sleep(random.randrange(2, 4))
s_price = (get_user(slave))['sale_price']
if (debug):
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][DEBUG] >>> {slave} в процессе абуза [{s_price}р]')
if (id_used):
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][ABS] > Заабузил {slave}')
if (settings['abuse_slaves']['AUTO_FET']):
fetter(slave)
time.sleep(random.random() * 2 + random.random() * 3)
make_job(slave)
time.sleep(random.randrange(1, 3) + random.random())
id_used = False
# update balance
me = get_user(local_id)
balance = me['balance']
time.sleep(random.randrange(settings['abuse_slaves']['PAUSE'], (settings['abuse_slaves']['PAUSE'] + 30)))
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# Кража рабов у топа игроков
# config.py - steal_top
def steal_top():
top = (get_top())['list']
users = []
[users.append(x['id']) for x in top]
random.shuffle(users)
while True:
for target in users:
info = get_user(target)
if info['balance'] >= 2147000000: continue
targets_slaves = get_slaves(target)
slaves_to_steal = get_slaves_to_steal(targets_slaves)
random.shuffle(slaves_to_steal)
if len(slaves_to_steal) > 0:
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][TOP] > Найдено {len(slaves_to_steal)} раба(ов) для кражи ({target})')
for slave in slaves_to_steal:
buy(slave)
time.sleep(random.randrange(2, 4))
if (settings['steal_top']['AUTO_FET']):
fetter(slave)
time.sleep(random.random() + random.randrange(0, 2))
make_job(slave)
if (debug):
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][DEBUG] >>> украл {slave} у {target}')
time.sleep((random.randrange(1, 3) + random.randrange(0, 2)) + min(0.9, 155 / len(slaves_to_steal)))
time.sleep(random.random())
time.sleep(random.randrange(2, 4))
time.sleep(random.randrange(settings['steal_top']['PAUSE'], (settings['steal_top']['PAUSE'] + 7)))
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# Покупка несуществующий id
# config.py - abuse_unknowns
def abuse_unknowns():
min_id = -325325252
max_id = -32352522
while True:
targets = []
[targets.append(random.randrange(min_id, max_id)) for _ in range(settings['abuse_unknowns']['TR_COUNT'])]
targets = set(targets)
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][UNK] > Сгенерировал список из {len(targets)} id')
for target in targets:
info = get_user(target)
if ((info['price'] >= settings['abuse_unknowns']['MIN_PRICE']) and (info['price'] <= settings['abuse_unknowns']['MAX_PRICE'])):
buy(target)
time.sleep(random.randrange(1, 3))
if (settings['abuse_unknowns']['AUTO_FET']):
fetter(target)
if (debug):
print_log(f'[{datetime.datetime.now().strftime("%d-%m-%Y %H:%M")}][DEBUG] >>> (UNK) Купил {target}')
time.sleep(random.randrange(settings['abuse_unknowns']['PAUSE'], (settings['abuse_unknowns']['PAUSE'] + 5)) + random.random())
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# //////////////////////////////////////////////////////////////////////////////
# just start
if __name__ == '__main__':
do_start()
Thread(target=update_me).start()
if (settings['job_slaves']['ENABLED']):
Thread(target=job_niggers).start()
if (settings['job_slaves']['MULTI-THREAD']):
Thread(target=job_niggers).start()
if (settings['fet_slaves']['ENABLED']):
Thread(target=fet_niggers).start()
if (settings['fet_slaves']['MULTI-THREAD']):
Thread(target=fet_niggers).start()
if (len(settings['steal_target']['TARGETS'])):
Thread(target=steal_niggers).start()
if (settings['steal_target']['MULTI-THREAD']):
Thread(target=steal_niggers).start()
if (settings['abuse_slaves']['ENABLED']):
Thread(target=abuse_niggers).start()
if (settings['abuse_slaves']['MULTI-THREAD']):
Thread(target=abuse_niggers).start()
if (settings['steal_top']['ENABLED']):
Thread(target=steal_top).start()
if (settings['steal_top']['MULTI-THREAD']):
Thread(target=steal_top).start()
if (settings['abuse_unknowns']['ENABLED']):
Thread(target=abuse_unknowns).start()
if (settings['abuse_unknowns']['MULTI-THREAD']):
Thread(target=abuse_unknowns).start()