11
This commit is contained in:
+47
-1
@@ -625,7 +625,7 @@ class JX3Service:
|
||||
|
||||
|
||||
async def shuijimingpian(self, force: str, body:str, server:str) -> Dict[str, Any]:
|
||||
"""角色名片"""
|
||||
"""随机名片"""
|
||||
return_data = self._init_return_data()
|
||||
|
||||
# 获取配置中的 Token
|
||||
@@ -651,3 +651,49 @@ class JX3Service:
|
||||
return_data["code"] = 200
|
||||
|
||||
return return_data
|
||||
|
||||
|
||||
async def yanhuachaxun(self, server: str, name:str ) -> Dict[str, Any]:
|
||||
"""烟花查询"""
|
||||
return_data = self._init_return_data()
|
||||
|
||||
# 获取配置中的 Token
|
||||
token = self._config.get("jx3api_token", "")
|
||||
if token == "":
|
||||
return_data["msg"] = "系统未配置API访问Token"
|
||||
return return_data
|
||||
|
||||
# 1. 构造请求参数
|
||||
params = {"server": server, "name": name,"token": token}
|
||||
|
||||
# 2. 调用基础请求
|
||||
data: Optional[Dict[str, Any]] = await self._base_request(
|
||||
"jx3_yanhuachaxun", "GET", params=params
|
||||
)
|
||||
|
||||
if not data:
|
||||
return_data["msg"] = "获取接口信息失败"
|
||||
return return_data
|
||||
|
||||
# 3. 处理返回数据 (直接提取图片 URL)
|
||||
# 格式化时间
|
||||
for item in data:
|
||||
timestamp = item.get("time")
|
||||
if timestamp and isinstance(timestamp, (int, float)):
|
||||
# 修复时间戳:原代码显示这里是毫秒级,除以 1000
|
||||
item["time"] = datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d %H:%M:%S")
|
||||
else:
|
||||
item["time"] = "未知时间" # 确保即使 time 字段缺失也不会报错
|
||||
|
||||
# 4. 加载模板
|
||||
try:
|
||||
return_data["temp"] = load_template("yanhuan.html")
|
||||
except FileNotFoundError as e:
|
||||
logger.error(f"加载模板失败: {e}")
|
||||
return_data["msg"] = "系统错误:模板文件不存在"
|
||||
return return_data
|
||||
|
||||
return_data["data"]["list"] = data
|
||||
return_data["code"] = 200
|
||||
|
||||
return return_data
|
||||
|
||||
@@ -166,5 +166,15 @@
|
||||
"force":"万花",
|
||||
"token":""
|
||||
}
|
||||
},
|
||||
"jx3_yanhuachaxun":{
|
||||
"url":"https://www.jx3api.com/data/fireworks/records",
|
||||
"method":"GET",
|
||||
"description":"此接口用于查询烟花赠送与接收的历史记录,数据可能存在遗漏",
|
||||
"params":{
|
||||
"server": "唯我独尊",
|
||||
"name": "萝莉",
|
||||
"token":""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -308,6 +308,22 @@ class Jx3ApiPlugin(Star):
|
||||
yield event.plain_result("猪脑过载,请稍后再试")
|
||||
|
||||
|
||||
@jx3.command("烟花")
|
||||
async def jx3_yanhuachaxun(self, event: AstrMessageEvent,server: str = "梦江南", name: str = "飞翔大野猪"):
|
||||
"""剑三 烟花 服务器 角色"""
|
||||
try:
|
||||
data= await self.jx3fun.yanhuachaxun(server,name)
|
||||
if data["code"] == 200:
|
||||
url = await self.html_render(data["temp"], data["data"], options={})
|
||||
yield event.image_result(url)
|
||||
else:
|
||||
yield event.plain_result(data["msg"])
|
||||
return
|
||||
except Exception as e:
|
||||
logger.error(f"功能函数执行错误: {e}")
|
||||
yield event.plain_result("猪脑过载,请稍后再试")
|
||||
|
||||
|
||||
async def terminate(self):
|
||||
"""可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。"""
|
||||
# 关闭数据库连接
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>烟花记录</title>
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Microsoft YaHei', Arial, sans-serif;
|
||||
background: #f1f2f6;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
text-align: center; /* ★ 让容器内标题更自然居中 */
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 32px;
|
||||
margin-bottom: 25px;
|
||||
color: #222;
|
||||
font-weight: 800;
|
||||
text-align: center; /* ★ 强制居中 */
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 16px rgba(0,0,0,0.08);
|
||||
margin-top: 10px;
|
||||
text-align: left; /* 不影响表格内容 */
|
||||
}
|
||||
|
||||
thead {
|
||||
background: #d93939;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
th, td {
|
||||
padding: 14px 12px;
|
||||
border-bottom: 1px solid #eee;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
tbody tr:hover {
|
||||
background: #fff2f2;
|
||||
}
|
||||
|
||||
.text-col {
|
||||
max-width: 360px;
|
||||
line-height: 1.5em;
|
||||
word-break: break-word;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h1>烟花记录</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>服务器</th>
|
||||
<th>烟花名称</th>
|
||||
<th>使用地点</th>
|
||||
<th>释放角色</th>
|
||||
<th>接收角色</th>
|
||||
<th>释放时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% for m in list %}
|
||||
<tr>
|
||||
<td>{{ m.server }}</td>
|
||||
<td>{{ m.name }}</td>
|
||||
<td>{{ m.map_name }}</td>
|
||||
<td>{{ m.sender }}</td>
|
||||
<td>{{ m.receive }}</td>
|
||||
<td>{{ m.time }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,14 +1,59 @@
|
||||
import http.client
|
||||
import datetime
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import httpx
|
||||
|
||||
conn = http.client.HTTPSConnection("api.t1qq.com")
|
||||
payload = ''
|
||||
headers = {
|
||||
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
||||
'Accept': '*/*',
|
||||
'Host': 'api.t1qq.com',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
conn.request("GET", "/api/tool/wzrr/ydtp?key=vBpEzoiC9z5A9c9Nn83IhLn6M9&id=489048724", payload, headers)
|
||||
res = conn.getresponse()
|
||||
data = res.read()
|
||||
print(data)
|
||||
def format_body(data: dict) -> str:
|
||||
return json.dumps(data, separators=(',', ':'))
|
||||
|
||||
|
||||
def gen_ts() -> str:
|
||||
return f"{datetime.datetime.now():%Y%m%d%H%M%S%f}"[:-3]
|
||||
|
||||
|
||||
def gen_xsk(data: str) -> str:
|
||||
data += "@#?.#@"
|
||||
secret = "MaYoaMQ3zpWJFWtN9mqJqKpHrkdFwLd9DDlFWk2NnVR1mChVRI6THVe6KsCnhpoR"
|
||||
return hmac.new(secret.encode(), msg=data.encode(), digestmod=hashlib.sha256).hexdigest()
|
||||
|
||||
async def post_url(url, proxy: dict = None, headers: str = None, timeout: int = 300, data: dict = None):
|
||||
async with httpx.AsyncClient(proxies=proxy, follow_redirects = True) as client:
|
||||
resp = await client.post(url, timeout = timeout, headers = headers, data = data)
|
||||
result = resp.text
|
||||
return result
|
||||
|
||||
async def get_arena_data(token: str) -> dict:
|
||||
param = {
|
||||
"gameVersion":0,
|
||||
"forceId":-1,
|
||||
"zone": "",
|
||||
"server": "",
|
||||
"ts": gen_ts()
|
||||
}
|
||||
param = format_body(param)
|
||||
device_id = token.split("::")[1]
|
||||
headers = {
|
||||
'Host': 'm.pvp.xoyo.com',
|
||||
'accept': 'application/json',
|
||||
'deviceid': device_id,
|
||||
'platform': 'ios',
|
||||
'gamename': 'jx3',
|
||||
'clientkey': '1',
|
||||
'cache-control': 'no-cache',
|
||||
'apiversion': '1',
|
||||
'sign': 'true',
|
||||
'token': token,
|
||||
'Content-Type': 'application/json',
|
||||
'Connection': 'Keep-Alive',
|
||||
'User-Agent': 'SeasunGame/178 CFNetwork/1240.0.2 Darwin/20.5.0',
|
||||
"x-sk": gen_xsk(param)
|
||||
}
|
||||
data = await post_url(url="https://w.pvp.xoyo.com/api/h5/parser/cd-process/get-by-role", data=param, headers=headers)
|
||||
return json.loads(data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import asyncio
|
||||
token = input()
|
||||
ans = asyncio.run(get_arena_data(token))
|
||||
print(ans)
|
||||
Reference in New Issue
Block a user