增加宏查找功能

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}")
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:
await macro_select_waiter(event) # type: ignore
return # ✅ 防止空 MessageChain
data = await self.jx3fun.hong1(kungfu)
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:
yield event.plain_result("选择宏超时,已取消")
return
except Exception:
logger.error("宏选择发生异常", exc_info=True)
return
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["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
+10
View File
@@ -297,5 +297,15 @@
"type": "horse",
"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>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>未来战场日历</title>
<pre class="e-jx3qixue-area">
{"version":"v20251030","xf":"易筋经","sq":"1,1,1,1,1,1,1,9,5,7","client":"std"}
</pre>
<style>
body {
font-family: "Microsoft YaHei", Arial, sans-serif;
background: #f1f2f6;
padding: 20px;
margin: 0;
}
<h1>如果你是第一次接触易筋经PVE,或者代练or代清,想寻找一个快速入门打输出的方式</h1>
h1 {
text-align: center;
font-size: 32px;
font-weight: 800;
margin-bottom: 25px;
color: #222;
}
<p>
<strong>
<span style="font-size: 32px;">
<span style="text-decoration: line-through; color: #ff0000;">
推荐武学助手!
👉
<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 {
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);
}
<p>&nbsp;</p>
.calendar th {
background: #d93939;
color: white;
padding: 12px;
font-size: 18px;
border: 1px solid #eee;
}
<p>
<span style="color: #ff0000;">
<strong>
<span style="font-size: 32px;">
PS:2026.1.8更新 明面优化武学助手实则重大削弱 实在不想动脑可以用。
</span>
</strong>
</span>
</p>
.calendar td {
vertical-align: top;
padding: 6px;
width: 14.2%;
border: 1px solid #eee;
min-height: 120px;
background: #fff;
}
<p>
<span style="color: #ff0000;">
<strong>
<span style="font-size: 32px;">
<img src="https://cdn.jx3box.com/upload/post/2026/1/16/89351_630300.png" />
</span>
</strong>
</span>
</p>
.date-label {
font-size: 14px;
color: #666;
font-weight: bold;
margin-bottom: 6px;
}
<p>&nbsp;</p>
.event-card {
background: #fff7f7;
border: 1px solid #f0dada;
border-radius: 6px;
padding: 6px;
margin-top: 6px;
font-size: 14px;
line-height: 1.4em;
}
<p>
<strong>
<span style="font-size: 28px;">
加速:紫武默认1段or2段(头鞋附魔+加速大酒) 橙武推荐2段以上
</span>
</strong>
</p>
.event-title {
font-weight: bold;
color: #222;
}
<h2>秘籍选择:</h2>
/* 鼠标悬停卡片高亮 */
.event-card:hover {
background: #ffeaea;
}
<p style="font-size: 22px;">
<img class="e-jx3-icon" src="https://icon.jx3box.com/icon/419.png" alt="419" />
1效果回豆 2伤害 1会心
</p>
/* 当日高亮,可选 */
.today {
background: #fef3c7;
}
<p style="font-size: 22px;">
<img class="e-jx3-icon" src="https://icon.jx3box.com/icon/428.png" alt="428" />
1效果回豆 3伤害
</p>
</style>
</head>
<body>
<p style="font-size: 22px;">
<img class="e-jx3-icon" src="https://icon.jx3box.com/icon/434.png" alt="434" />
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>
<tr>
<th>周日</th>
<th>周一</th>
<th>周二</th>
<th>周三</th>
<th>周四</th>
<th>周五</th>
<th>周六</th>
</tr>
</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>
<p style="font-size: 28px;">
<img class="e-jx3-icon" src="https://icon.jx3box.com/icon/445.png" alt="445" />
<span style="font-size: 22px;">
3持续
<span style="color: #ff0000;">
1回豆效果(加速2段以上建议点,看个人手感)
</span>
</span>
</p>