刷马推送

This commit is contained in:
2026-01-20 14:46:08 +08:00
parent 480208eb61
commit 13efe7fc4c
7 changed files with 137 additions and 7 deletions
+56
View File
@@ -72,5 +72,61 @@
"default": [] "default": []
} }
} }
},
"smxx": {
"description": "刷马消息推送",
"type": "object",
"items": {
"enable": {
"description": "刷马消息推送功能开关",
"type": "bool",
"default": false,
"hint": "是否启用剑网三开刷马消息推送功能。"
},
"time": {
"description": "获取最新消息循环时间",
"type": "int",
"default": 60,
"hint": "请求最新消息的循环时间,单位秒。"
},
"umos": {
"description": "推送列表",
"type": "list",
"hint": "可以填写多个会话唯一ID。",
"items": {
"type": "string",
"description": "会话唯一ID,可通过/std获取"
},
"default": []
}
}
},
"ctxx": {
"description": "赤兔消息推送",
"type": "object",
"items": {
"enable": {
"description": "赤兔消息推送功能开关",
"type": "bool",
"default": false,
"hint": "是否启用剑网三开赤兔消息推送功能。"
},
"time": {
"description": "获取最新消息循环时间",
"type": "int",
"default": 60,
"hint": "请求最新消息的循环时间,单位秒。"
},
"umos": {
"description": "推送列表",
"type": "list",
"hint": "可以填写多个会话唯一ID。",
"items": {
"type": "string",
"description": "会话唯一ID,可通过/std获取"
},
"default": []
}
}
} }
} }
+6 -1
View File
@@ -1,3 +1,4 @@
# pyright: reportArgumentType=false
import asyncio import asyncio
import json import json
import aiofiles import aiofiles
@@ -23,6 +24,7 @@ class AsyncTask:
self.conf = config self.conf = config
self.jx3fun = jx3fun self.jx3fun = jx3fun
self.server = self.conf.get("server", "梦江南")
self.file_path = StarTools.get_data_dir("astrbot_plugin_jx3") / "local_async.json" self.file_path = StarTools.get_data_dir("astrbot_plugin_jx3") / "local_async.json"
self._file_lock = asyncio.Lock() self._file_lock = asyncio.Lock()
@@ -31,6 +33,7 @@ class AsyncTask:
logger.info(f"获取后台数据缓存文件路径成功:{self.file_path}") logger.info(f"获取后台数据缓存文件路径成功:{self.file_path}")
"""===================== 本地读写 =====================""" """===================== 本地读写 ====================="""
async def set_local_data(self, key: str, value): async def set_local_data(self, key: str, value):
@@ -109,8 +112,10 @@ class AsyncTask:
async def init_tasks(self): async def init_tasks(self):
settings = [ settings = [
("kfjk", "开服监控", lambda: self.jx3fun.kaifu("梦江南")), ("kfjk", "开服监控", lambda: self.jx3fun.kaifu(self.server)),
("xwzx", "新闻资讯", lambda: self.jx3fun.xinwen()), ("xwzx", "新闻资讯", lambda: self.jx3fun.xinwen()),
("smxx", "刷马消息", lambda: self.jx3fun.shuamamsg(self.server,type="horse",subtype="foreshow")),
("ctxx", "赤兔消息", lambda: self.jx3fun.shuamamsg(self.server,type="chitu-horse",subtype="share_msg")),
] ]
for key, name, fetch in settings: for key, name, fetch in settings:
+33 -1
View File
@@ -413,7 +413,8 @@ class JX3Service:
return_data = self._init_return_data() return_data = self._init_return_data()
# 提取字段可能返回列表 # 提取字段可能返回列表
data: Optional[List[Dict[str, Any]]] = await self._base_request("jx3_xinweng", "GET") data: Optional[List[Dict[str, Any]]] = await self._base_request(
"jx3_xinweng", "GET")
if not data or not isinstance(data, list): if not data or not isinstance(data, list):
return_data["msg"] = "获取接口信息失败或数据格式错误" return_data["msg"] = "获取接口信息失败或数据格式错误"
@@ -440,6 +441,37 @@ class JX3Service:
return return_data return return_data
async def shuamamsg(self,server:str,type:str,subtype:str) -> Dict[str, Any]:
"""刷马消息"""
return_data = self._init_return_data()
params = {"server": server, "type": type, "subtype": subtype}
# 提取字段可能返回列表
data: Optional[List[Dict[str, Any]]] = await self._base_request(
"jx3box_shuamamsg", "GET", params=params)
if not data:
return_data["msg"] = "获取接口信息失败或数据格式错误"
return return_data
try:
#
new_msg = data.get("list")[0]
return_data["status"] = new_msg.get('id')
result_msg = f"{server}\n"
result_msg += f"{new_msg.get('content')}\n"
result_msg += f"{new_msg.get('created_at')}\n"
return_data["data"] = result_msg
return_data["code"] = 200
except Exception as e:
logger.error(f"jigai 数据处理时出错: {e}")
return_data["msg"] = "处理接口返回信息时出错"
return return_data
async def jinjia(self, server: str, limit:str) -> Dict[str, Any]: async def jinjia(self, server: str, limit:str) -> Dict[str, Any]:
"""区服金价""" """区服金价"""
return_data = self._init_return_data() return_data = self._init_return_data()
+12
View File
@@ -250,5 +250,17 @@
"client": "std", "client": "std",
"page": "1" "page": "1"
} }
},
"jx3box_shuamamsg":{
"url":"https://next2.jx3box.com/api/game/reporter/horse",
"method":"GET",
"description":"魔盒获取最新的刷马消息",
"params":{
"pageIndex": "1",
"pageSize": "3",
"server": "梦江南",
"type": "horse",
"subtype": "foreshow"
}
} }
} }
+3 -2
View File
@@ -1,5 +1,6 @@
{ {
"kfjk": true, "kfjk": true,
"xwzx": 0, "xwzx": 3174,
"whgg": 0 "smxx": 0,
"ctxx": 0
} }
+14
View File
@@ -555,6 +555,20 @@ class Jx3ApiPlugin(Star):
yield event.plain_result(return_msg) yield event.plain_result(return_msg)
@jx3.command("刷马推送")
async def jx3_shuamamsg(self, event: AstrMessageEvent):
"""剑三 刷马推送"""
return_msg = await self.at.get_task_info("smxx")
yield event.plain_result(return_msg)
@jx3.command("赤兔推送")
async def jx3_chitusg(self, event: AstrMessageEvent):
"""剑三 赤兔推送"""
return_msg = await self.at.get_task_info("ctxx")
yield event.plain_result(return_msg)
async def terminate(self): async def terminate(self):
"""可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。""" """可选择实现异步的插件销毁方法,当插件被卸载/停用时会调用。"""
if self.at: if self.at:
+11 -1
View File
@@ -311,9 +311,19 @@
</div> </div>
<div class="command"> <div class="command">
<div class="cmd-name">新闻推送</div> <div class="cmd-name">新闻推送</div>
<div class="cmd-desc">查看新闻推送状态的后台运行状况</div> <div class="cmd-desc">推送最新的官方新闻资讯</div>
<div class="cmd-usage">剑三 新闻推送</div> <div class="cmd-usage">剑三 新闻推送</div>
</div> </div>
<div class="command">
<div class="cmd-name">刷马推送</div>
<div class="cmd-desc">推送最新的刷马消息</div>
<div class="cmd-usage">剑三 刷马推送</div>
</div>
<div class="command">
<div class="cmd-name">赤兔推送</div>
<div class="cmd-desc">推送最新的赤兔消息</div>
<div class="cmd-usage">剑三 赤兔推送</div>
</div>
</div> </div>
</div> </div>