From 6bca545f72dc3c478c5fc04a761ab2ed2f48e2c0 Mon Sep 17 00:00:00 2001 From: Inkar-Suki Date: Fri, 6 Sep 2024 13:54:29 +0800 Subject: [PATCH] [feat]update horse info --- src/plugins/jx3/calculator/__init__.py | 8 ++-- src/plugins/jx3/horse/api.py | 47 ++++++++++++++++++- src/plugins/jx3/serendipity/without_jx3api.py | 4 +- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/src/plugins/jx3/calculator/__init__.py b/src/plugins/jx3/calculator/__init__.py index e9f279889..1748ef367 100644 --- a/src/plugins/jx3/calculator/__init__.py +++ b/src/plugins/jx3/calculator/__init__.py @@ -18,10 +18,10 @@ async def _(event: GroupMessageEvent, args: Message = CommandArg()): if args.extract_plain_text() == "": return - if not checker(str(event.user_id), 10) and Sign.get_coin(str(event.user_id)) < 500: - await calc.finish(error(10)) - if not checker(str(event.user_id), 10): - Sign.reduce(str(event.user_id), 500) + # if not checker(str(event.user_id), 10) and Sign.get_coin(str(event.user_id)) < 500: + # await calc.finish(error(10)) + # if not checker(str(event.user_id), 10): + # Sign.reduce(str(event.user_id), 500) arg = args.extract_plain_text().split(" ") if len(arg) not in [1, 2]: await calc.finish("唔……参数不正确哦,请检查后重试~") diff --git a/src/plugins/jx3/horse/api.py b/src/plugins/jx3/horse/api.py index 2b5d3f8fb..8d787b9d6 100644 --- a/src/plugins/jx3/horse/api.py +++ b/src/plugins/jx3/horse/api.py @@ -21,7 +21,31 @@ async def get_horse_reporter(server: str, group_id: str = ""): # 数据来源@J map = i["map_name"] msg = f"{content}\n刷新时间:{time_}\n地图:{map}" return msg - + +def is_in_current_cycle(timestamp): + now = datetime.now() + current_weekday = now.weekday() + if current_weekday == 1 and now.hour < 7: + start_of_cycle = datetime(now.year, now.month, now.day, 7) - timedelta(days=7) + else: + days_to_tuesday = (current_weekday - 1) % 7 + start_of_cycle = datetime(now.year, now.month, now.day, 7) - timedelta(days=days_to_tuesday) + end_of_cycle = start_of_cycle + timedelta(days=6, hours=24) + timestamp_dt = datetime.fromtimestamp(timestamp) + return start_of_cycle <= timestamp_dt < end_of_cycle + +def is_in_current_week(timestamp): + now = datetime.now() + current_weekday = now.weekday() + if current_weekday == 0 and now.hour < 7: + start_of_week = datetime(now.year, now.month, now.day, 7) - timedelta(days=7) + else: + days_to_monday = current_weekday % 7 + start_of_week = datetime(now.year, now.month, now.day, 7) - timedelta(days=days_to_monday) + end_of_week = start_of_week + timedelta(days=7) + timestamp_dt = datetime.fromtimestamp(timestamp) + return start_of_week <= timestamp_dt < end_of_week + async def get_horse_next_spawn(server, group_id: str): def parse_info(raw_msg: str, flush_time: str): next_times = {} @@ -52,6 +76,14 @@ def parse_info(raw_msg: str, flush_time: str): server = server_mapping(server, group_id) if not server: return PROMPT.ServerNotExist + ct_data = await get_api(f"https://next2.jx3box.com/api/game/reporter/horse?pageIndex=1&pageSize=50&server={server}&type=chitu-horse&subtype=share_msg") + chitu_flushed = False + if is_in_current_cycle(ct_data["data"]["list"][0]["time"]): + chitu_flushed = True + dl_data = await get_api(f"https://next2.jx3box.com/api/game/reporter/horse?pageIndex=1&pageSize=50&server{server}&type=dilu-horse&subtype=share_msg") + dilu_flushed = False + if is_in_current_week(dl_data["data"]["list"][0]["time"]): + dilu_flushed = True web_data = await get_api(f"https://next2.jx3box.com/api/game/reporter/horse?pageIndex=1&pageSize=50&server={server}&type=horse&subtype=npc_chat") msg = {} ft = {} @@ -69,4 +101,15 @@ def parse_info(raw_msg: str, flush_time: str): for map_name in maps: final_msg += f"\n{map_name}\n" + parse_info(msg[map_name], ft[map_name]) + "\n-------------------------------" final_msg = final_msg[1:-1] - return server + "·马场告示\n" + final_msg + "\n今日未收到的卢刷新通知!" if not dl_flag else final_msg + "\n今日将有的卢出世,敬请留意!" \ No newline at end of file + add_msg = "" + if dilu_flushed: + add_msg = add_msg + "\n的卢本周期内已刷新!(周期:一周)" + else: + add_msg = add_msg + "\n的卢本周期内未刷新!(周期:一周)" + if chitu_flushed: + add_msg = add_msg + "\n赤兔本周期内已刷新!(周期:周二7点至下周一7点)" + else: + add_msg = add_msg + "\n赤兔本周期内未刷新!(周期:周二7点至下周一7点)" + final_msg = server + "·马场告示\n" + final_msg + "\n今日未收到的卢刷新通知!" if not dl_flag else final_msg + "\n今日将有的卢出世,敬请留意!" + final_msg = final_msg + "\n-------------------------------" + add_msg + return final_msg \ No newline at end of file diff --git a/src/plugins/jx3/serendipity/without_jx3api.py b/src/plugins/jx3/serendipity/without_jx3api.py index 1804f3fed..5b19c7624 100644 --- a/src/plugins/jx3/serendipity/without_jx3api.py +++ b/src/plugins/jx3/serendipity/without_jx3api.py @@ -3,6 +3,7 @@ from src.tools.basic.jx3 import gen_ts, gen_xsk, format_body from src.plugins.jx3.bind import get_player_local_data, Player +from src.plugins.majsoul.koromo import sort_list_of_dicts import json import re @@ -114,9 +115,10 @@ async def get_jx3pet_data(self, server: str, name: str): } ) self.jx3pet = serendipities + print(self.jx3pet) async def integration(self, server: str, name: str): await self.get_tuilan_data(server, name) await self.get_my_data(server, name) await self.get_jx3pet_data(server, name) - return merge_dict_lists(self.jx3pet, merge_dict_lists(self.tl, self.my)) \ No newline at end of file + return sort_list_of_dicts(merge_dict_lists(merge_dict_lists(self.tl, self.my), self.jx3pet), "time")[::-1] \ No newline at end of file