优化Wiki命令,减少材料地图太大而崩溃的可能性

This commit is contained in:
CMHopeSunshine 2022-12-17 17:28:07 +08:00
parent 8ad13992e0
commit 8cb2ba77c2
2 changed files with 4 additions and 3 deletions

View File

@ -269,10 +269,9 @@ async def _(event: MessageEvent, state: T_State, type: str = Arg('type'), name:
await total_wiki.finish()
elif len(matches) == 1 and len(list(matches.values())[0]) == 1:
final_name = list(matches.values())[0][0]
temp_type = list(matches.keys())[0]
if type in {'材料', '攻略', '图鉴'}:
type = list(matches.keys())[0] + type
if type.endswith(('攻略', '图鉴')) and type.startswith(('原魔', '圣遗物', '武器', '七圣召唤')):
type = f'{type[-2:]}图鉴'
type = f'{temp_type}图鉴' if temp_type != '角色' else f'{temp_type}{type}'
try:
await total_wiki.finish(
MessageSegment.image(API[type].format(proxy=config.github_proxy, name=final_name)))

View File

@ -163,6 +163,8 @@ async def get_full_map(names: List[str], map_: str):
models.XYPoint(x1_temp, y1_temp),
models.XYPoint(x2_temp, y2_temp),
points)]
if len(group_point[0][2]) > 400:
group_point = img.k_means_points(points, 600)
lt_point = group_point[0][0]
rb_point = group_point[0][1]
min_point = XYPoint(x=min(min_point.x, lt_point.x), y=min(min_point.y, lt_point.y))