diff --git a/.idea/iOSAI.iml b/.idea/iOSAI.iml
index f571432..df5cbff 100644
--- a/.idea/iOSAI.iml
+++ b/.idea/iOSAI.iml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index db8786c..c27b771 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c9ba169..a95bbca 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,19 @@
-
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
@@ -60,8 +68,8 @@
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"git-widget-placeholder": "main",
- "javascript.nodejs.core.library.configured.version": "22.18.0",
- "javascript.nodejs.core.library.typings.version": "22.18.1",
+ "javascript.nodejs.core.library.configured.version": "20.17.0",
+ "javascript.nodejs.core.library.typings.version": "20.17.58",
"last_opened_file_path": "F:/company code/AI item/20250820/iOSAI",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
@@ -78,7 +86,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -88,7 +119,6 @@
-
@@ -103,6 +133,11 @@
+
+
+
+
+
@@ -162,6 +197,13 @@
+
+
+
+
+
+
+
@@ -197,15 +239,16 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Utils/LogManager.py b/Utils/LogManager.py
index 09a4e9e..2f5913b 100644
--- a/Utils/LogManager.py
+++ b/Utils/LogManager.py
@@ -206,6 +206,12 @@
# return True
# return False
+
+
+
+
+
+
# -*- coding: utf-8 -*-
import datetime
import io
@@ -219,22 +225,57 @@ from pathlib import Path
import requests
# ========= 全局:强制 UTF-8(打包 EXE / 无控制台也生效) =========
+# def _force_utf8_everywhere():
+# os.environ.setdefault("PYTHONUTF8", "1")
+# os.environ.setdefault("PYTHONIOENCODING", "utf-8")
+# # windowed 模式下 stdout/stderr 可能没有 buffer,这里做保护包装
+# try:
+# if getattr(sys.stdout, "buffer", None):
+# sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
+# except Exception:
+# pass
+# try:
+# if getattr(sys.stderr, "buffer", None):
+# sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
+# except Exception:
+# pass
+#
+# _force_utf8_everywhere()
+
+
+# ========= 全局:强制 UTF-8 + 关闭缓冲(运行期立刻生效) =========
def _force_utf8_everywhere():
os.environ.setdefault("PYTHONUTF8", "1")
+ # 等价于 -u:让 stdout/stderr 无缓冲
+ os.environ.setdefault("PYTHONUNBUFFERED", "1")
os.environ.setdefault("PYTHONIOENCODING", "utf-8")
- # windowed 模式下 stdout/stderr 可能没有 buffer,这里做保护包装
+
+ # 若是 3.7+,优先用 reconfigure 实时改流
try:
- if getattr(sys.stdout, "buffer", None):
- sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
- except Exception:
- pass
- try:
- if getattr(sys.stderr, "buffer", None):
- sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
+ if hasattr(sys.stdout, "reconfigure"):
+ sys.stdout.reconfigure(encoding="utf-8", errors="replace",
+ line_buffering=True, write_through=True)
+ elif getattr(sys.stdout, "buffer", None):
+ # 退路:重新包一层,启用行缓冲 + 直写
+ sys.stdout = io.TextIOWrapper(
+ sys.stdout.buffer, encoding="utf-8",
+ errors="replace", line_buffering=True
+ )
+ except Exception:
+ pass
+
+ try:
+ if hasattr(sys.stderr, "reconfigure"):
+ sys.stderr.reconfigure(encoding="utf-8", errors="replace",
+ line_buffering=True, write_through=True)
+ elif getattr(sys.stderr, "buffer", None):
+ sys.stderr = io.TextIOWrapper(
+ sys.stderr.buffer, encoding="utf-8",
+ errors="replace", line_buffering=True
+ )
except Exception:
pass
-_force_utf8_everywhere()
# ===========================================================
diff --git a/Utils/Requester.py b/Utils/Requester.py
index b6ef644..b2c1176 100644
--- a/Utils/Requester.py
+++ b/Utils/Requester.py
@@ -1,5 +1,6 @@
import requests
from Entity.Variables import prologueList
+from Utils.LogManager import LogManager
BaseUrl = "https://crawlclient.api.yolozs.com/api/common/"
@@ -23,16 +24,19 @@ class Requester():
# 翻译
@classmethod
def translation(cls, msg, country="英国"):
- parame = {
- "msg": msg,
- "country": country,
- }
- url = "http://ai.zhukeping.com/translation"
- result = requests.request(url=url, json=parame, method="POST")
- json = result.json()
- data = json.get("data")
- print(data)
- return data
+ try:
+ parame = {
+ "msg": msg,
+ "country": country,
+ }
+ url = "http://ai.zhukeping.com/translation"
+ result = requests.request(url=url, json=parame, method="POST")
+ json = result.json()
+ data = json.get("data")
+ print(data)
+ return data
+ except Exception as e:
+ LogManager.method_error(f"翻译失败,报错的原因:{e}","翻译失败")
# ai聊天
@classmethod
diff --git a/build.bat b/build.bat
index 98699cd..eb76759 100644
--- a/build.bat
+++ b/build.bat
@@ -1,24 +1,25 @@
-python -m nuitka Module/Main.py ^
- --standalone ^
- --msvc=latest ^
- --windows-console-mode=disable ^
- --remove-output ^
- --output-dir=out ^
- --output-filename=IOSAI ^
- --include-package=Module,Utils,Entity,script ^
- --include-module=flask ^
- --include-module=flask_cors ^
- --include-module=jinja2 ^
- --include-module=werkzeug ^
- --include-module=cv2 ^
- --include-module=numpy ^
- --include-module=lxml ^
- --include-module=lxml.etree ^
- --include-module=requests ^
- --include-module=urllib3 ^
- --include-module=certifi ^
- --include-module=idna ^
- --include-data-dir="E:/Code/python/iOSAI/SupportFiles=SupportFiles" ^
- --include-data-dir="E:/Code/python/iOSAI/resources=resources" ^
- --include-data-files="E:/Code/python/iOSAI/resources/iproxy/*=resources/iproxy/" ^
- --windows-icon-from-ico=resources/icon.ico
\ No newline at end of file
+python -m nuitka "Module/Main.py"^
+ --standalone^
+ --msvc=latest^
+ --windows-console-mode=disable^
+ --remove-output^
+ --output-dir=out^
+ --output-filename=IOSAI^
+ --include-package=Module,Utils,Entity,script^
+ --include-module=flask^
+ --include-module=flask_cors^
+ --include-module=jinja2^
+ --include-module=werkzeug^
+ --include-module=cv2^
+ --include-module=numpy^
+ --include-module=lxml^
+ --include-module=lxml.etree^
+ --include-module=requests^
+ --include-module=urllib3^
+ --include-module=certifi^
+ --include-module=idna^
+ --include-data-dir="F:/company code/AI item/20250820/iOSAI/SupportFiles=SupportFiles"^
+ --include-data-dir="F:/company code/AI item/20250820/iOSAI/resources=resources"^
+ --include-data-files="F:/company code/AI item/20250820/iOSAI/resources/iproxy/*=resources/iproxy/"^
+ --windows-icon-from-ico="F:/company code/AI item/20250820/iOSAI/resources/icon.ico"
+
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..cfac345
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,5 @@
+facebook_wda==1.5.1
+Flask==3.1.2
+flask_cors==6.0.1
+Requests==2.32.5
+tidevice==0.12.10
diff --git a/script/ScriptManager.py b/script/ScriptManager.py
index 4d7674c..71cab47 100644
--- a/script/ScriptManager.py
+++ b/script/ScriptManager.py
@@ -276,6 +276,11 @@ class ScriptManager():
retries = 0
while not event.is_set():
try:
+ anchor = AiUtils.pop_aclist_first()
+
+ if not anchor:
+ break
+
self.greetNewFollowers(udid, needReply, event)
return # 成功执行就退出
except Exception as e:
@@ -467,21 +472,27 @@ class ScriptManager():
LogManager.method_info("找到输入框了, 准备发送一条打招呼消息", "关注打招呼", udid)
print("打招呼的数据", ev.prologueList)
- LogManager.method_info(f"打招呼的数据:{ev.prologueList}", "关注打招呼", udid)
+ LogManager.method_info(f"传递的打招呼的数据:{ev.prologueList}", "关注打招呼", udid)
# 准备打招呼的文案
text = random.choice(ev.prologueList)
- LogManager.method_info(f"打招呼完成", "关注打招呼", udid)
+ LogManager.method_info(f"取出打招呼的数据,{text}, 判断是否需要翻译", "关注打招呼", udid)
isContainChniese = AiUtils.contains_chinese(text)
+
+
if isContainChniese:
# 翻译成主播国家的语言
+ LogManager.method_info(f"需要翻译:{text}, 即将进行翻译", "关注打招呼", udid)
+
msg = Requester.translation(text, anchorCountry)
+ LogManager.method_info(f"翻译成功:{msg}, ", "关注打招呼", udid)
+
else:
msg = text
- LogManager.method_info(f"翻译后的私信数据:{msg}", "关注打招呼", udid)
+ LogManager.method_info(f"即将发送的私信内容:{msg}", "关注打招呼", udid)
# 准备发送一条信息
@@ -492,7 +503,7 @@ class ScriptManager():
time.sleep(1)
else:
print("无法发送信息")
- LogManager.method_info(f"给主播{anchor.anchorId} 发送消息失败", "关注打招呼", udid)
+ LogManager.method_info(f"给主播{aid} 发送消息失败", "关注打招呼", udid)
# 接着下一个主播
# removeModelFromAnchorList(anchor)
@@ -500,8 +511,8 @@ class ScriptManager():
goBack(4)
else:
- print(f"{anchor.anchorId}:该主播没有视频")
- LogManager.method_info(f"{anchor.anchorId}:该主播没有视频", "关注打招呼", udid)
+ print(f"{aid}:该主播没有视频")
+ LogManager.method_info(f"{aid}:该主播没有视频", "关注打招呼", udid)
goBack(3)
session.appium_settings({"snapshotMaxDepth": 15})
continue