diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5e2bccd..1201d60 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,8 +5,9 @@ + + - @@ -254,7 +255,7 @@ - + - @@ -344,7 +353,7 @@ - - + + \ No newline at end of file diff --git a/Utils/ControlUtils.py b/Utils/ControlUtils.py index 7c2c915..cac7c58 100644 --- a/Utils/ControlUtils.py +++ b/Utils/ControlUtils.py @@ -178,9 +178,6 @@ class ControlUtils(object): center_y = rect.y + rect.height // 2 session.tap(left_x, center_y) - - - # 点击一个随机范围 @classmethod def tap_mini_cluster(cls, center_x: int, center_y: int, session, points=5, duration_ms=60): diff --git a/Utils/Requester.py b/Utils/Requester.py index 0f3330d..b2039b5 100644 --- a/Utils/Requester.py +++ b/Utils/Requester.py @@ -17,7 +17,7 @@ class Requester(): "vvtoken": token, } url = BaseUrl + cls.prologue - result = requests.get(headers=headers, url=url) + result = requests.get(headers=headers, url=url, verify=False) json = result.json() data = json.get("data") for i in data: @@ -29,15 +29,18 @@ class Requester(): @classmethod def translation(cls, msg, country="英国"): try: + if country == "": + country = "英国" + param = { "msg": msg, "country": country, } url = "https://ai.yolozs.com/translation" - result = requests.post(url=url, json=param) + result = requests.post(url=url, json=param, verify=False) - LogManager.info(f"翻译 请求的参数:{param}") - LogManager.info(f"翻译,状态码:{result.status_code},服务器返回的内容:{result.text}") + LogManager.info(f"翻译 请求的参数:{param}", "翻译") + LogManager.info(f"翻译,状态码:{result.status_code},服务器返回的内容:{result.text}", "翻译") if result.status_code != 200: LogManager.error(f"翻译失败,状态码:{result.status_code},服务器返回的内容:{result.text}") @@ -69,7 +72,7 @@ class Requester(): try: url = "https://ai.yolozs.com/chat" - result = requests.post(url=url, json=param) + result = requests.post(url=url, json=param, verify=False) json = result.json() data = json.get("answer", {}) session_id = json.get("conversation_id", {}) diff --git a/script/ScriptManager.py b/script/ScriptManager.py index 6578c27..07d131a 100644 --- a/script/ScriptManager.py +++ b/script/ScriptManager.py @@ -380,7 +380,6 @@ class ScriptManager(): session.appium_settings({"snapshotMaxDepth": 15}) continue - time.sleep(2) # 找到并点击第一个视频 @@ -481,7 +480,8 @@ class ScriptManager(): if isContainChniese: # 翻译成主播国家的语言 - LogManager.method_info(f"需要翻译:{text},参数为:国家为{anchorCountry}, 即将进行翻译", "关注打招呼", udid) + LogManager.method_info(f"需要翻译:{text},参数为:国家为{anchorCountry}, 即将进行翻译", + "关注打招呼", udid) msg = Requester.translation(text, anchorCountry) @@ -514,8 +514,14 @@ class ScriptManager(): if followButton is not None: # LogManager.method_info("找到关注按钮了", "关注打招呼", udid) # followButton.click() + x, y, w, h = followButton.bounds + cx = int(x + w / 2) + cy = int(y + h / 2) + # 随机偏移 ±5 px(可自己改范围) + cx += random.randint(-5, 5) + cy += random.randint(-5, 5) - ControlUtils.micro_swipe_click(session, element=followButton, dist_min=1, dist_max=10, repeat=1) + ControlUtils.tap_mini_cluster(cx, cy, session) else: @@ -738,7 +744,8 @@ class ScriptManager(): last_msg_text = last_msg else: - LogManager.method_info(f"对方发送的消息不是语言,随机挑选作为最后一条进行回复:{last_msg}", "检测消息", udid) + LogManager.method_info(f"对方发送的消息不是语言,随机挑选作为最后一条进行回复:{last_msg}", + "检测消息", udid) last_msg_text = random.choice(text_list) if AiUtils.contains_chinese(last_msg_text):