-
Notifications
You must be signed in to change notification settings - Fork 0
/
anti_bot_detection.py
84 lines (70 loc) · 2.62 KB
/
anti_bot_detection.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
import random
import time
import pyautogui as auto
SCREEN_RESOLUTION_MARGIN = 50
MAX_CAMERA_ROTATIONS = 5
def anti_bot_detection(fire_chance, min_pause, max_pause, compass, screen_resolution, min_drag_time, max_drag_time):
"""
:param fire_chance:
:type fire_chance: float
:param min_pause:
:type min_pause: int
:param max_pause:
:type max_pause: int
:param compass:
:type compass: list of int
:param screen_resolution:
:type screen_resolution: tuple of int
:param min_drag_time:
:type min_drag_time: int
:param max_drag_time:
:type max_drag_time: int
:return:
"""
if random.random() > fire_chance:
function_index = random.randint(0, 2)
if function_index == 0:
pause(min_pause, max_pause)
elif function_index == 1:
camera(compass, screen_resolution, min_drag_time, max_drag_time)
elif function_index == 2:
movement()
def pause(min_pause, max_pause):
"""
:param min_pause:
:type min_pause: int
:param max_pause:
:type max_pause: int
:return:
"""
pause_duration = random.randint(min_pause, max_pause)
time.sleep(pause_duration)
def camera(compass, screen_resolution, min_drag_time, max_drag_time):
"""
:param compass:
:type compass: list of int
:param screen_resolution:
:type screen_resolution: tuple of int
:param min_drag_time:
:type min_drag_time: int
:param max_drag_time:
:type max_drag_time: int
:return:
"""
amount_of_movements = random.randint(1, MAX_CAMERA_ROTATIONS)
for i in range(amount_of_movements):
if bool(random.randint(0, 1)):
x_drag_destination = random.randint(SCREEN_RESOLUTION_MARGIN, screen_resolution[0] // 2 - 15)
else:
x_drag_destination = random.randint(screen_resolution[0] // 2 - 15,
screen_resolution[0] - SCREEN_RESOLUTION_MARGIN)
y_drag_destination = random.randint(SCREEN_RESOLUTION_MARGIN, screen_resolution[1] // 2 - 5)
drag_time = random.randint(min_drag_time, max_drag_time)
auto.moveTo(screen_resolution[0] // 2 - 15, screen_resolution[1] // 2 - 5, 0.5)
auto.dragTo(x_drag_destination, y_drag_destination, drag_time, button="middle")
auto.moveTo(compass[0], compass[1], 1)
auto.click()
auto.moveTo(screen_resolution[0] // 2 - 15, screen_resolution[1] // 2 - 5, 0.5)
auto.drag(0, 100, 1, button="middle")
def movement():
print("Anti bot detection function 'movement' not yet defined")