11
This commit is contained in:
@@ -251,7 +251,7 @@ class Jx3ApiPlugin(Star):
|
|||||||
parts = message_str.split()
|
parts = message_str.split()
|
||||||
# 解析消息内容
|
# 解析消息内容
|
||||||
if len(parts) > 1:
|
if len(parts) > 1:
|
||||||
params["serverName"] = parts[1] # 第二个参数为服务器
|
params["serverName"] = parts[1] # 服务器
|
||||||
# 获取数据
|
# 获取数据
|
||||||
data = api_data(custom_url,params)
|
data = api_data(custom_url,params)
|
||||||
|
|
||||||
@@ -280,11 +280,70 @@ class Jx3ApiPlugin(Star):
|
|||||||
|
|
||||||
url = await self.html_render(template_content, render_data, options)
|
url = await self.html_render(template_content, render_data, options)
|
||||||
yield event.image_result(url)
|
yield event.image_result(url)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"处理数据时出错: {e}")
|
||||||
|
yield event.plain_result("处理接口返回信息时出错")
|
||||||
|
|
||||||
|
|
||||||
|
@filter.command("剑三奇遇")
|
||||||
|
async def jx3_qiyu(self, event: AstrMessageEvent):
|
||||||
|
"""剑三奇遇 奇遇名称 服务器"""
|
||||||
|
# 接口URL
|
||||||
|
custom_url = "https://www.jianxiachaguan.cn/api2/aijx3-jxcg/game/get-adventure-record"
|
||||||
|
# 接口参数
|
||||||
|
params = {
|
||||||
|
"adventureName": "阴阳两界", # 默奇遇
|
||||||
|
"serverName": "眉间雪" # 默认服务器
|
||||||
|
}
|
||||||
|
# 获取消息内容
|
||||||
|
message_str = event.message_str.strip()
|
||||||
|
parts = message_str.split()
|
||||||
|
# 解析消息内容
|
||||||
|
if len(parts) > 1:
|
||||||
|
params["adventureName"] = parts[1] # 奇遇名称
|
||||||
|
if len(parts) > 2:
|
||||||
|
params["serverName"] = parts[2] # 第二个参数为服务器
|
||||||
|
# 获取数据
|
||||||
|
data = api_data(custom_url,params)
|
||||||
|
|
||||||
|
if not data:
|
||||||
|
yield event.plain_result("获取获取接口信息失败,请稍后再试")
|
||||||
|
return
|
||||||
|
|
||||||
|
#数据处理
|
||||||
|
for item in data:
|
||||||
|
# 格式化时间
|
||||||
|
if "time" in item:
|
||||||
|
dt = datetime.fromtimestamp(item["time"]/1000)
|
||||||
|
item["time"] = dt.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
# 传入模板渲染
|
||||||
|
try:
|
||||||
|
# 加载模板
|
||||||
|
try:
|
||||||
|
template_content = load_template("qiyuliebiao.html")
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
logger.error(f"加载模板失败: {e}")
|
||||||
|
yield event.plain_result("系统错误:模板文件不存在")
|
||||||
|
return
|
||||||
|
# 准备模板渲染数据
|
||||||
|
render_data = {
|
||||||
|
"items": data,
|
||||||
|
"server": params["serverName"],
|
||||||
|
"update_time": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
,"qiyuname": params["adventureName"]
|
||||||
|
}
|
||||||
|
# 调整渲染图片的尺寸
|
||||||
|
options = {
|
||||||
|
}
|
||||||
|
|
||||||
|
url = await self.html_render(template_content, render_data, options)
|
||||||
|
yield event.image_result(url)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"处理数据时出错: {e}")
|
logger.error(f"处理数据时出错: {e}")
|
||||||
yield event.plain_result("处理接口返回信息时出错")
|
yield event.plain_result("处理接口返回信息时出错")
|
||||||
|
|
||||||
|
|
||||||
async def terminate(self):
|
async def terminate(self):
|
||||||
"""可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。"""
|
"""可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。"""
|
||||||
@@ -159,7 +159,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
<tr {% if loop.index <= 3 %}class="highlight"{% endif %}>
|
<tr>
|
||||||
<td class="item-name">{{ item.name }}</td>
|
<td class="item-name">{{ item.name }}</td>
|
||||||
<td class="price">{{ item.price }}</td>
|
<td class="price">{{ item.price }}</td>
|
||||||
<td class="sample">{{ item.sample_size }}</td>
|
<td class="sample">{{ item.sample_size }}</td>
|
||||||
|
|||||||
@@ -164,7 +164,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
<tr {% if loop.index <= 3 %}class="highlight"{% endif %}>
|
<tr>
|
||||||
<td class="date">{{ item.date }}</td>
|
<td class="date">{{ item.date }}</td>
|
||||||
<td class="priceTieba">{{ item.priceTieba }}</td>
|
<td class="priceTieba">{{ item.priceTieba }}</td>
|
||||||
<td class="priceWanbaolou">{{ item.priceWanbaolou }}</td>
|
<td class="priceWanbaolou">{{ item.priceWanbaolou }}</td>
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>剑网3奇遇查询</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: 'Microsoft YaHei', sans-serif;
|
||||||
|
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
||||||
|
padding: 20px;
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
width: 1280px;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
background: linear-gradient(135deg, #4a90e2 0%, #2a5298 100%);
|
||||||
|
color: white;
|
||||||
|
padding: 25px 30px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.header h1 {
|
||||||
|
font-size: 32px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
.server-info {
|
||||||
|
font-size: 18px;
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
.summary {
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
padding: 15px 30px;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #495057;
|
||||||
|
border-bottom: 1px solid #e9ecef;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.items-count {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #4a90e2;
|
||||||
|
}
|
||||||
|
.update-time {
|
||||||
|
color: #6c757d;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.table-container {
|
||||||
|
padding: 0 30px 30px 30px;
|
||||||
|
overflow-x: auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-top: 20px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
|
||||||
|
color: white;
|
||||||
|
padding: 16px 20px;
|
||||||
|
text-align: left;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 16px;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
th:first-child {
|
||||||
|
border-top-left-radius: 8px;
|
||||||
|
}
|
||||||
|
th:last-child {
|
||||||
|
border-top-right-radius: 8px;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
padding: 14px 20px;
|
||||||
|
border-bottom: 1px solid #e9ecef;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #495057;
|
||||||
|
}
|
||||||
|
tr:nth-child(even) {
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
}
|
||||||
|
tr:hover {
|
||||||
|
background-color: #e9f7fe;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
.item-name {
|
||||||
|
font-weight: 500;
|
||||||
|
color: #2c3e50;
|
||||||
|
max-width: 500px;
|
||||||
|
}
|
||||||
|
.price {
|
||||||
|
text-align: right;
|
||||||
|
color: #e74c3c;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
.sample {
|
||||||
|
text-align: center;
|
||||||
|
color: #6c757d;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
background-color: #343a40;
|
||||||
|
color: #f8f9fa;
|
||||||
|
padding: 15px 30px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.highlight {
|
||||||
|
background-color: #fff3cd;
|
||||||
|
}
|
||||||
|
@media (max-width: 1320px) {
|
||||||
|
body {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 1280px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<h1>剑网3奇遇查询</h1>
|
||||||
|
<div class="server-info">奇遇名称:{{ qiyuname }} 服务器: {{ server }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="summary">
|
||||||
|
<div class="items-count">共找到 <strong>{{ items|length }}</strong> 条记录</div>
|
||||||
|
<div class="update-time">数据更新时间: {{ update_time }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-container">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 20%; text-align: center;">奇遇名称</th>
|
||||||
|
<th style="width: 20%; text-align: center;">服务器</th>
|
||||||
|
<th style="width: 25%; text-align: center;">角色名称</th>
|
||||||
|
<th style="width: 35%; text-align: center;">触发时间</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in items %}
|
||||||
|
<tr>
|
||||||
|
<td class="adventureName">{{ item.adventureName }}</td>
|
||||||
|
<td class="server">{{ server }}</td>
|
||||||
|
<td class="gameName">{{ item.gameName }}</td>
|
||||||
|
<td class="time">{{ item.time }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="footer">
|
||||||
|
© 2025 剑网3奇遇查询系统 | 数据仅供参考,以游戏内实际价格为准
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user