From 82c4c70dee387e0e01fe7ec4658b250950c8fc0d Mon Sep 17 00:00:00 2001 From: qsc Date: Fri, 16 Jan 2026 23:04:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/jx3_service.py | 46 ++++++++++++++++++++++++++++++++++++++------ data/api_config.json | 11 +++++++++++ main.py | 19 ++++++++++++++++-- 3 files changed, 68 insertions(+), 8 deletions(-) diff --git a/core/jx3_service.py b/core/jx3_service.py index 7573dff..d5e72ae 100644 --- a/core/jx3_service.py +++ b/core/jx3_service.py @@ -966,20 +966,18 @@ class JX3Service: result_msg = "" for record in records: - result_msg += f"区服:{record['server']} 标签:{record['tieba']}\n" + result_msg += f"区服:{record['server']} 标签:{record['tieba']}\n\n" - list_id = 1 for item in record["data"]: - result_msg += f"{list_id}、标题:{item['title']}\n" + result_msg += f"标题:{item['title']}\n" result_msg += f"地址:{item['url']}\n" result_msg += f"ID:{item['tid']}\n" result_msg += f"内容:{item['text']}\n" result_msg += ( - f"时间:{datetime.fromtimestamp(item['time']).strftime('%Y-%m-%d %H:%M:%S')}\n" + f"时间:{datetime.fromtimestamp(item['time']).strftime('%Y-%m-%d %H:%M:%S')}\n\n" ) - list_id += 1 - result_msg += "\n" + result_msg += "\n\n" except Exception as e: logger.error(f"处理返回数据失败: {e}") @@ -988,4 +986,40 @@ class JX3Service: return_data["data"] = result_msg return_data["code"] = 200 + return return_data + + + async def bagua(self, type: str) -> Dict[str, Any]: + """八卦""" + return_data = self._init_return_data() + + # 1. 构造请求参数 + params = {"class": type, "limit": "5", "token": self.token} + + # 2. 调用基础请求 + data: Optional[Dict[str, Any]] = await self._base_request( + "jx3_bagua", "GET", params=params + ) + + # 3. 处理返回数据 + try: + if not data: + result_msg = f"未找到相关 {type} 记录。\n" + result_msg += f"可选范围:818 616 鬼网三 鬼网3 树洞 记录 教程 街拍 故事 避雷 吐槽 提问" + else: + result_msg = f"类型:{type} 的最新记录如下:\n\n" + + for item in data: + result_msg += f"{item['title']}\n" + result_msg += f"分区:{item['zone']} 服务器:{item['server']}\n" + result_msg += f"所属吧:{item['name']}\n" + result_msg += f"链接:https://tieba.baidu.com/p/{item['url']}\n" + result_msg += f"日期:{item['date']}\n\n" + except Exception as e: + logger.exception("处理返回数据失败") + return_data["msg"] = "处理返回数据失败" + + return_data["data"] = result_msg + return_data["code"] = 200 + return return_data \ No newline at end of file diff --git a/data/api_config.json b/data/api_config.json index 36ec3d0..bd1f653 100644 --- a/data/api_config.json +++ b/data/api_config.json @@ -228,5 +228,16 @@ "uid": "", "token": "" } + }, + "jx3_bagua":{ + "url":"https://www.jx3api.com/data/tieba/random", + "method":"GET", + "description":"此接口用于随机搜索指定分类的贴吧帖子,支持多种分类查询。", + "params":{ + "class": "", + "server": "", + "limit": "10", + "token": "" + } } } \ No newline at end of file diff --git a/main.py b/main.py index af5cbbf..e6d3b47 100644 --- a/main.py +++ b/main.py @@ -490,8 +490,8 @@ class Jx3ApiPlugin(Star): @jx3.command("骗子") - async def jx3_pianzhi(self, event: AstrMessageEvent,qq: str = ""): - """剑三 骗子 服务器 天数""" + async def jx3_pianzhi(self, event: AstrMessageEvent,qq: str): + """剑三 骗子 QQ""" try: data= await self.jx3fun.pianzhi(qq) if data["code"] == 200: @@ -504,6 +504,21 @@ class Jx3ApiPlugin(Star): yield event.plain_result("猪脑过载,请稍后再试") + @jx3.command("八卦") + async def jx3_bagua(self, event: AstrMessageEvent,type: str): + """剑三 八卦 类型""" + try: + data= await self.jx3fun.bagua(type) + 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("猪脑过载,请稍后再试") + + @jx3.command("开服监控") async def jx3_kaifhujiank(self, event: AstrMessageEvent): """剑三 开服监控"""