功能补充

This commit is contained in:
qsc
2026-01-25 23:19:28 +08:00
parent 9b4779aeae
commit 6ebddccc80
5 changed files with 31 additions and 9 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ class AsyncTask:
async def init_tasks(self):
settings = [
("kfjk", "开服监控", lambda: self.jx3fun.kaifu(self.server)),
("xwzx", "新闻资讯", lambda: self.jx3fun.xinwen()),
("xwzx", "新闻资讯", lambda: self.jx3fun.xinwen(1)),
("smxx", "刷马消息", lambda: self.jx3fun.shuamamsg(self.server,type="horse",subtype="foreshow")),
("ctxx", "赤兔消息", lambda: self.jx3fun.shuamamsg(self.server,type="chitu-horse",subtype="share_msg")),
]
+14
View File
@@ -150,6 +150,20 @@ class JX3Commands(Star):
yield event.plain_result("猪脑过载,请稍后再试")
async def jx3_xinwen(self, event: AstrMessageEvent,num:int = 5):
"""剑三 新闻"""
try:
data= await self.jx3fun.xinwen(num)
if data["code"] == 200:
yield event.plain_result(data["data"])
else:
yield event.plain_result(data["msg"])
return
except Exception as e:
logger.error(f"功能函数执行错误: {e}")
yield event.plain_result("猪脑过载,请稍后再试")
async def jx3_keju(self, event: AstrMessageEvent,subject: str, limit: int = 5):
"""剑三 科举"""
try:
+4 -3
View File
@@ -542,13 +542,14 @@ class JX3Service:
return return_data
async def xinwen(self) -> Dict[str, Any]:
async def xinwen(self, num:int) -> Dict[str, Any]:
"""新闻资讯"""
return_data = self._init_return_data()
params = {"limit": num}
# 提取字段可能返回列表
data: Optional[List[Dict[str, Any]]] = await self._base_request(
"jx3_xinweng", "GET")
"jx3_xinweng", "GET", params=params)
if not data or not isinstance(data, list):
return_data["msg"] = "获取接口信息失败或数据格式错误"
@@ -561,7 +562,7 @@ class JX3Service:
result_msg = "新闻资讯推送\n"
# 仅展示前1条,避免消息过长
for i, item in enumerate(data[:1], 1):
for i, item in enumerate(data[:num], 1):
result_msg += f"{i}. {item.get('title', '无标题')}\n"
result_msg += f"时间:{item.get('date', '未知时间')}\n"
result_msg += f"链接:{item.get('url', '无链接')}\n"