Files
iOSAI/Utils/Requester.py

55 lines
1.7 KiB
Python
Raw Normal View History

2025-08-12 18:53:06 +08:00
import requests
2025-08-27 21:58:55 +08:00
from Entity.Variables import prologueList
2025-09-09 20:45:02 +08:00
from Utils.LogManager import LogManager
2025-08-12 18:53:06 +08:00
2025-08-18 19:22:20 +08:00
BaseUrl = "https://crawlclient.api.yolozs.com/api/common/"
2025-08-12 18:53:06 +08:00
2025-08-11 22:06:48 +08:00
class Requester():
2025-08-12 18:53:06 +08:00
comment = "comment"
prologue = "prologue"
2025-08-14 14:30:36 +08:00
2025-08-12 18:53:06 +08:00
@classmethod
2025-08-18 22:20:23 +08:00
def requestPrologue(cls, token):
2025-09-10 16:54:05 +08:00
try:
headers = {
"vvtoken": token,
}
url = BaseUrl + cls.prologue
result = requests.get(headers=headers, url=url)
json = result.json()
data = json.get("data")
for i in data:
prologueList.append(i)
except Exception as e:
LogManager.method_error(f"获取requestPrologue失败,报错的原因:{e}", "获取requestPrologue异常")
2025-08-12 18:53:06 +08:00
# 翻译
@classmethod
2025-09-08 21:42:09 +08:00
def translation(cls, msg, country="英国"):
2025-09-09 20:45:02 +08:00
try:
parame = {
"msg": msg,
"country": country,
}
2025-09-10 16:54:05 +08:00
url = "https://ai.yolozs.com/translation"
2025-09-09 20:45:02 +08:00
result = requests.request(url=url, json=parame, method="POST")
json = result.json()
data = json.get("data")
print(data)
return data
except Exception as e:
2025-09-10 16:54:05 +08:00
LogManager.method_error(f"翻译失败,报错的原因:{e}", "翻译失败异常")
2025-08-11 22:06:48 +08:00
2025-08-12 18:53:06 +08:00
# ai聊天
2025-08-11 22:06:48 +08:00
@classmethod
2025-08-12 18:53:06 +08:00
def chatToAi(cls, param):
2025-09-10 16:54:05 +08:00
try:
url = "https://ai.yolozs.com/chat"
result = requests.request(url=url, json=param, method="POST")
json = result.json()
data = json.get("data", {})
return data
except Exception as e:
LogManager.method_error(f"ai聊天失败,ai聊天出现异常,报错的原因:{e}", "ai聊天接口异常")