-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_replay_actions.py
49 lines (36 loc) · 1.37 KB
/
create_replay_actions.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
import json
import time
from ActionRecorder import ActionRecorder
import settings as st
import random
class RedEnvelope:
def __init__(self, _number, _money, _description):
self.number = _number
self.money = _money
self.description = _description
def __str__(self):
return f'{self.number} {self.money} {self.description}'
def record_input(input_str):
global actions_base, recorder, action_id
for char in input_str:
pos = next(
(key for key in actions_base["keyBoard"] if key["description"] == char), None)["params"]["pos"]
recorder.record_touch(action_id, pos)
action_id += 1
delay_time = random.uniform(st.randomDelayMin, st.randomDelayMax)
print(f"【随机延时】将随机延时 {delay_time/1000} 秒")
recorder.record_delay(action_id, delay_time/1000)
action_id += 1
def envelope2action(red_envelope: RedEnvelope):
global recorder
record_input(str(red_envelope.number))
record_input(str(red_envelope.money))
return recorder
with open("actions/actions_base.json", 'r',encoding="utf-8") as f:
actions_base = json.load(f)
recorder = ActionRecorder(device_id="16b4be26")
action_id = 1
red_envelope = RedEnvelope(3, 5, "新年快乐")
print(red_envelope)
recorder = envelope2action(red_envelope)
recorder.save_to_file(f"actions_{time.time()}.json")