-
Notifications
You must be signed in to change notification settings - Fork 1
/
tiktok-lite.like-comment.py
106 lines (84 loc) · 2.6 KB
/
tiktok-lite.like-comment.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
#!/bin/env python
import random
from autoclick import helpers, db
from autoclick.helpers import (
device,
tap,
random_sleep,
locateCenterOnImage,
screenshot,
)
total_like = 0
total_comment = 0
imgs = {
'like_button': './imgs/tiktok_lite/like_button.png',
'comment_button': './imgs/tiktok_lite/comment_button.png',
'submit_comment_button': './imgs/tiktok_lite/submit_comment_button.png',
'close_comment_button': './imgs/tiktok_lite/close_comment_button.png',
}
def search_like_button():
return locateCenterOnImage(
imgs.get('like_button'), screenshot(), confidence=0.8
)
def scroll_page():
return helpers.device.swipe(292, 1050, 292, 163, 0.1)
def close_comment():
close_comment = locateCenterOnImage(
imgs.get('close_comment_button'), screenshot(), confidence=0.9
)
if close_comment:
tap(*close_comment)
def auto_comment():
global total_comment
# random_sleep()
has_comment_button = locateCenterOnImage(
imgs.get('comment_button'), screenshot(), confidence=0.8
)
# klik tombol komentar
if has_comment_button:
tap(*has_comment_button)
# random_sleep()
has_comment_input = device(
className='android.widget.EditText', textContains='Add comment'
)
if has_comment_input:
position = has_comment_input.center()
tap(position[0], position[1])
tap(position[0], position[1])
random_sleep()
comment_text = random.choice(db.comments)
print(f'comment: {comment_text}')
device.send_keys(comment_text)
# has_comment_input.set_text(comment_text)
random_sleep()
submit_button = locateCenterOnImage(
imgs.get('submit_comment_button'), screenshot(), confidence=0.9
)
tap(*submit_button)
total_comment += 1
random_sleep()
# start tiktok lite activity
device.app_stop_all()
device.app_start(
'com.zhiliaoapp.musically.go',
'com.ss.android.ugc.aweme.main.homepage.MainActivity',
)
device.wait_activity(
'com.ss.android.ugc.aweme.main.homepage.MainActivity', timeout=10
)
while True:
if random.randint(1, 999) % 2 == 1:
continue
random_sleep()
has_like_button = search_like_button()
if has_like_button:
tap(*has_like_button)
print('Like')
total_like += 1
if random.randint(1, 999) % 2 == 0:
auto_comment()
close_comment()
random_sleep()
print(f'like: {total_like}')
print(f'comment: {total_comment}')
scroll_page()