Skip to content

Commit

Permalink
<jx3>[feat]wufang dps calculator;[feat]calculator color follow school…
Browse files Browse the repository at this point in the history
…;[feat]fix subscribe error
  • Loading branch information
HornCopper committed Sep 6, 2024
2 parents 02628bd + 6bca545 commit e8744cb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
47 changes: 45 additions & 2 deletions src/plugins/jx3/horse/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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 = {}
Expand All @@ -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今日将有的卢出世,敬请留意!"
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
4 changes: 3 additions & 1 deletion src/plugins/jx3/serendipity/without_jx3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
return sort_list_of_dicts(merge_dict_lists(merge_dict_lists(self.tl, self.my), self.jx3pet), "time")[::-1]

0 comments on commit e8744cb

Please sign in to comment.