-
Notifications
You must be signed in to change notification settings - Fork 1
/
tiktok-lite.like-comment2.py
executable file
·117 lines (93 loc) · 2.98 KB
/
tiktok-lite.like-comment2.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
#!/bin/env python
import random
from autoclick import helpers, db
from autoclick.helpers import (
send_notify,
device,
tap,
random_sleep,
locateCenterOnImage,
screenshot,
changeScreenSize,
)
total_like = 0
total_comment = 0
imgs = {
"like_button": "./imgs/tiktok_lite/like_button2.png",
"comment_button": "./imgs/tiktok_lite/comment_button2.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.82)
def scroll_page():
return helpers.device.swipe(100, 350, 100, 10, 0.1)
def close_comment():
close_comment = locateCenterOnImage(
imgs.get("close_comment_button"), screenshot(), confidence=0.8
)
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.9
)
print("has_comment_button")
print(has_comment_button)
# 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}")
send_notify(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.8
)
print("submit button")
print(submit_button)
tap(*submit_button)
total_comment += 1
random_sleep()
# auto_comment()
# sys.exit()
# start the tiktok lite activity
changeScreenSize(400, 400, 120)
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()
print("has_like_button")
print(has_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}")
send_notify(f"like: {total_like} \n comment: {total_comment}")
scroll_page()