增加宏查找功能

This commit is contained in:
qsc
2026-01-28 21:57:24 +08:00
parent 3fa47f70d5
commit 3248bdbaf9
4 changed files with 220 additions and 145 deletions
+65 -32
View File
@@ -274,44 +274,77 @@ class JX3Commands(Star):
logger.error(f"功能函数执行错误: {e}") logger.error(f"功能函数执行错误: {e}")
yield event.plain_result("猪脑过载,请稍后再试") yield event.plain_result("猪脑过载,请稍后再试")
async def jx3_hong(self, event: AstrMessageEvent, name: str = "易筋经"):
async def jx3_hong(self, event: AstrMessageEvent, kungfu: str = "易筋经"):
"""剑三 宏 心法""" """剑三 宏 心法"""
# 获取宏列表
macros = "已查询到的内容"
if not macros:
yield event.plain_result(f"未搜索到与【{name}】相关的宏")
return
yield event.plain_result(macros)
user_id = event.get_sender_id()
@session_waiter(timeout=10)
async def macro_select_waiter(controller: SessionController,event: AstrMessageEvent):
if event.get_sender_id() != user_id:
return
msg = event.message_str.strip()
logger.debug(msg)
await event.send(
MessageChain().message("收到")
)
controller.stop()
try: try:
await macro_select_waiter(event) # type: ignore data = await self.jx3fun.hong1(kungfu)
return # ✅ 防止空 MessageChain if data["code"] == 200:
yield event.plain_result(data["msg"])
else:
yield event.plain_result(f"未搜索到与【{kungfu}】相关的宏")
return
except Exception as e:
logger.error(f"功能函数执行错误: {e}")
yield event.plain_result("猪脑过载,请稍后再试")
# 获取用户ID
user_id = event.get_sender_id()
# 等等用户回复
@session_waiter(timeout=15)
async def macro_select_waiter(controller: SessionController,new_event: AstrMessageEvent):
if new_event.get_sender_id() != user_id:
return
msg = new_event.get_message_str().strip()
if not msg.isdigit():
await new_event.send(
MessageChain().message("输入异常,结束会话")
)
controller.stop()
return
num = int(msg)
if num < 1 or num > data["data"]["num"]:
await new_event.send(
MessageChain().message("无效序号,结束会话")
)
controller.stop()
return
try:
data1 = await self.jx3fun.hong2(data["data"]["pid"][num])
if data1["code"] != 200:
await new_event.send(
MessageChain().message("获取详细宏数据失败")
)
controller.stop()
return
url = await self.html_render(data1["temp"], {}, options={})
msg_text = data1["data"]
chain = MessageChain()
chain.url_image(url)
chain.message(msg_text)
await new_event.send(chain)
except Exception as e:
logger.error(f"功能函数执行错误: {e}")
await new_event.send(
MessageChain().message("猪脑过载,请稍后再试")
)
controller.stop()
try:
await macro_select_waiter(event)
except TimeoutError: except TimeoutError:
yield event.plain_result("选择宏超时,已取消") yield event.plain_result("选择宏超时,已取消")
return
except Exception: except Exception:
logger.error("宏选择发生异常", exc_info=True) logger.error("宏选择发生异常", exc_info=True)
return
async def jx3_jinjia(self, event: AstrMessageEvent,server: str = "", limit:str = "15"): async def jx3_jinjia(self, event: AstrMessageEvent,server: str = "", limit:str = "15"):
+69
View File
@@ -1235,4 +1235,73 @@ class JX3Service:
return_data["temp"] = content return_data["temp"] = content
return_data["code"] = 200 return_data["code"] = 200
return return_data
async def hong1(self, kungfu: str) -> Dict[str, Any]:
"""宏 心法"""
return_data = self._init_return_data()
# 1. 构造请求参数
params = {"kungfu": kungfu}
# 2. 调用基础请求
data: Optional[Dict[str, Any]] = await self._base_request(
"jx3box_hong", "GET", params=params, out_key=""
)
logger.debug(data)
if not data:
return_data["msg"] = "未找到该心法一键宏"
return return_data
# 提取ID
pid_list = [0]
msg = ""
n = 1
try:
for m in data:
msg += f"{n}{m['author']}\t{m['item_version']}\n"
pid_list.append(m["pid"])
n += 1
return_data["msg"] = msg
return_data["data"]["pid"] = pid_list
return_data["data"]["num"] = n
return_data["code"] = 200
except Exception as e:
logger.exception("处理返回数据失败")
return_data["msg"] = "处理返回数据失败"
return return_data
async def hong2(self, pid: str) -> Dict[str, Any]:
"""宏 心法"""
return_data = self._init_return_data()
# 发起请求
url = f"https://cms.jx3box.com/api/cms/post/{pid}"
logger.debug(f"获取宏接口地址:{url}")
data = await self._api.get(url, out_key="data")
# 验证数据
if not data:
return_data["msg"] = "获取宏数据异常"
return return_data
# 4. 处理数据
try:
return_data["temp"] = data["post_content"]
msg = ""
for m in data["post_meta"]["data"]:
msg += f"宏名称:{m['name']}\n"
msg += f"使用说明:{m['desc']}\n"
msg += f"宏脚本:\n{m['macro']}\n\n"
return_data["data"] = msg
return_data["code"] = 200
except Exception as e:
logger.exception("处理返回数据失败")
return_data["msg"] = "处理返回数据失败"
return return_data return return_data
+10
View File
@@ -297,5 +297,15 @@
"type": "horse", "type": "horse",
"subtype": "foreshow" "subtype": "foreshow"
} }
},
"jx3box_hong":{
"url":"https://next2.jx3box.com/api/macro/tops",
"method":"GET",
"description":"魔盒获取宏推荐列表",
"params":{
"kungfu": "易筋经",
"size": "10",
"client": "std"
}
} }
} }
+76 -113
View File
@@ -1,127 +1,90 @@
<!DOCTYPE html> <pre class="e-jx3qixue-area">
<html lang="zh-CN"> {"version":"v20251030","xf":"易筋经","sq":"1,1,1,1,1,1,1,9,5,7","client":"std"}
<head> </pre>
<meta charset="UTF-8">
<title>未来战场日历</title>
<style> <h1>如果你是第一次接触易筋经PVE,或者代练or代清,想寻找一个快速入门打输出的方式</h1>
body {
font-family: "Microsoft YaHei", Arial, sans-serif;
background: #f1f2f6;
padding: 20px;
margin: 0;
}
h1 { <p>
text-align: center; <strong>
font-size: 32px; <span style="font-size: 32px;">
font-weight: 800; <span style="text-decoration: line-through; color: #ff0000;">
margin-bottom: 25px; 推荐武学助手!
color: #222; 👉
} <img src="https://cdn.jx3box.com/upload/post/2025/4/18/89351_9335671.png" />
</span>
<span style="text-decoration: line-through;">
经过提交建议优化后的武学助手真的很好用!
</span>
</span>
</strong>
</p>
.calendar { <p>&nbsp;</p>
width: 100%;
max-width: 1200px;
margin: 0 auto;
border-collapse: collapse;
background: white;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.calendar th { <p>
background: #d93939; <span style="color: #ff0000;">
color: white; <strong>
padding: 12px; <span style="font-size: 32px;">
font-size: 18px; PS:2026.1.8更新 明面优化武学助手实则重大削弱 实在不想动脑可以用。
border: 1px solid #eee; </span>
} </strong>
</span>
</p>
.calendar td { <p>
vertical-align: top; <span style="color: #ff0000;">
padding: 6px; <strong>
width: 14.2%; <span style="font-size: 32px;">
border: 1px solid #eee; <img src="https://cdn.jx3box.com/upload/post/2026/1/16/89351_630300.png" />
min-height: 120px; </span>
background: #fff; </strong>
} </span>
</p>
.date-label { <p>&nbsp;</p>
font-size: 14px;
color: #666;
font-weight: bold;
margin-bottom: 6px;
}
.event-card { <p>
background: #fff7f7; <strong>
border: 1px solid #f0dada; <span style="font-size: 28px;">
border-radius: 6px; 加速:紫武默认1段or2段(头鞋附魔+加速大酒) 橙武推荐2段以上
padding: 6px; </span>
margin-top: 6px; </strong>
font-size: 14px; </p>
line-height: 1.4em;
}
.event-title { <h2>秘籍选择:</h2>
font-weight: bold;
color: #222;
}
/* 鼠标悬停卡片高亮 */ <p style="font-size: 22px;">
.event-card:hover { <img class="e-jx3-icon" src="https://icon.jx3box.com/icon/419.png" alt="419" />
background: #ffeaea; 1效果回豆 2伤害 1会心
} </p>
/* 当日高亮,可选 */ <p style="font-size: 22px;">
.today { <img class="e-jx3-icon" src="https://icon.jx3box.com/icon/428.png" alt="428" />
background: #fef3c7; 1效果回豆 3伤害
} </p>
</style> <p style="font-size: 22px;">
</head> <img class="e-jx3-icon" src="https://icon.jx3box.com/icon/434.png" alt="434" />
<body> 1伤害 1目标数量 1持续时间
</p>
<h1>未来战场日历</h1> <p style="font-size: 22px;">
<img class="e-jx3-icon" src="https://icon.jx3box.com/icon/1508.png" alt="1508" />
:3伤害 1会心 或者 2伤害 2会心(自己酌情选择)
</p>
<table class="calendar"> <p style="font-size: 22px;">
<img class="e-jx3-icon" src="https://icon.jx3box.com/icon/447.png" alt="447" />
2伤害 2CD
</p>
<thead> <p style="font-size: 28px;">
<tr> <img class="e-jx3-icon" src="https://icon.jx3box.com/icon/445.png" alt="445" />
<th>周日</th>
<th>周一</th> <span style="font-size: 22px;">
<th>周二</th> 3持续
<th>周三</th> <span style="color: #ff0000;">
<th>周四</th> 1回豆效果(加速2段以上建议点,看个人手感)
<th>周五</th> </span>
<th>周六</th> </span>
</tr> </p>
</thead>
<tbody>
{% for week in calendar_rows %}
<tr>
{% for cell in week %}
<td class="{% if cell.is_today %}today{% endif %}">
{% if cell.date %}
<div class="date-label">{{ cell.date }}</div>
{% for ev in cell.items %}
<div class="event-card">
<div class="event-title">{{ ev.war }}</div>
<div>{{ ev.battle }}</div>
</div>
{% endfor %}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>