mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 06:12:53 +08:00
修复原神资源查询地图api数据变更导致更新的地图不完全
This commit is contained in:
parent
30f356a2c7
commit
3cbd899daa
@ -286,6 +286,7 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能
|
|||||||
* 修复词条含有CQ回答的模糊匹配无法被解析
|
* 修复词条含有CQ回答的模糊匹配无法被解析
|
||||||
* 禁言检测图片在内存中获取图片hash
|
* 禁言检测图片在内存中获取图片hash
|
||||||
* B站订阅在群里中任意群管理员可以统一管理(原来为管理员1无法删除管理员2的订阅)
|
* B站订阅在群里中任意群管理员可以统一管理(原来为管理员1无法删除管理员2的订阅)
|
||||||
|
* 修复原神资源查询地图api数据变更导致更新的地图不完全
|
||||||
|
|
||||||
### 2022/8/27
|
### 2022/8/27
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,7 @@ __plugin_block_limit__ = {
|
|||||||
qr = on_command("原神资源查询", aliases={"原神资源查找"}, priority=5, block=True)
|
qr = on_command("原神资源查询", aliases={"原神资源查找"}, priority=5, block=True)
|
||||||
qr_lst = on_command("原神资源列表", priority=5, block=True)
|
qr_lst = on_command("原神资源列表", priority=5, block=True)
|
||||||
rex_qr = on_regex(".*?(在哪|在哪里|哪有|哪里有).*?", priority=5, block=True)
|
rex_qr = on_regex(".*?(在哪|在哪里|哪有|哪里有).*?", priority=5, block=True)
|
||||||
update_info = on_command("更新原神资源信息", permission=SUPERUSER, priority=1, block=True)
|
update_info = on_regex("^更新原神资源信息$", permission=SUPERUSER, priority=1, block=True)
|
||||||
|
|
||||||
|
|
||||||
@qr.handle()
|
@qr.handle()
|
||||||
|
|||||||
@ -172,28 +172,29 @@ async def download_map_init(semaphore: Semaphore, flag: bool = False):
|
|||||||
if data["message"] == "OK":
|
if data["message"] == "OK":
|
||||||
data = json.loads(data["data"]["info"]["detail"])
|
data = json.loads(data["data"]["info"]["detail"])
|
||||||
CENTER_POINT = (data["origin"][0], data["origin"][1])
|
CENTER_POINT = (data["origin"][0], data["origin"][1])
|
||||||
if not _map.exists():
|
if not _map.exists() or flag:
|
||||||
data = data["slices"]
|
data = data["slices"]
|
||||||
idx = 0
|
idx = 0
|
||||||
for _map_data in data[0]:
|
w_len = len(data[0])
|
||||||
map_url = _map_data["url"]
|
h_len = len(data)
|
||||||
await download_image(
|
for _map_data in data:
|
||||||
map_url,
|
for _map in _map_data:
|
||||||
map_path / f"{idx}.png",
|
map_url = _map["url"]
|
||||||
semaphore,
|
await download_image(
|
||||||
force_flag=flag,
|
map_url,
|
||||||
)
|
map_path / f"{idx}.png",
|
||||||
BuildImage(
|
semaphore,
|
||||||
0, 0, background=f"{map_path}/{idx}.png", ratio=MAP_RATIO
|
force_flag=flag,
|
||||||
).save()
|
)
|
||||||
idx += 1
|
BuildImage(
|
||||||
_w, h = BuildImage(0, 0, background=f"{map_path}/0.png").size
|
0, 0, background=f"{map_path}/{idx}.png", ratio=MAP_RATIO
|
||||||
w = _w * len(os.listdir(map_path))
|
).save()
|
||||||
map_file = BuildImage(w, h, _w, h, ratio=MAP_RATIO)
|
idx += 1
|
||||||
|
w, h = BuildImage(0, 0, background=f"{map_path}/0.png").size
|
||||||
|
map_file = BuildImage(w * w_len, h * h_len, w, h, ratio=MAP_RATIO)
|
||||||
for i in range(idx):
|
for i in range(idx):
|
||||||
map_file.paste(
|
img = BuildImage(0, 0, background=f"{map_path}/{i}.png")
|
||||||
BuildImage(0, 0, background=f"{map_path}/{i}.png")
|
await map_file.apaste(img)
|
||||||
)
|
|
||||||
map_file.save(f"{map_path}/map.png")
|
map_file.save(f"{map_path}/map.png")
|
||||||
else:
|
else:
|
||||||
logger.warning(f'获取原神地图失败 msg: {data["message"]}')
|
logger.warning(f'获取原神地图失败 msg: {data["message"]}')
|
||||||
@ -202,7 +203,7 @@ async def download_map_init(semaphore: Semaphore, flag: bool = False):
|
|||||||
except (TimeoutError, ConnectTimeout):
|
except (TimeoutError, ConnectTimeout):
|
||||||
logger.warning("下载原神地图数据超时....")
|
logger.warning("下载原神地图数据超时....")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"下载原神地图数据超时 {type(e)}:{e}")
|
logger.error(f"下载原神地图数据失败 {type(e)}:{e}")
|
||||||
|
|
||||||
|
|
||||||
# 下载资源类型数据
|
# 下载资源类型数据
|
||||||
|
|||||||
@ -178,8 +178,8 @@ class BuildImage:
|
|||||||
self.h = int(h)
|
self.h = int(h)
|
||||||
self.paste_image_width = int(paste_image_width)
|
self.paste_image_width = int(paste_image_width)
|
||||||
self.paste_image_height = int(paste_image_height)
|
self.paste_image_height = int(paste_image_height)
|
||||||
self.current_w = 0
|
self._current_w = 0
|
||||||
self.current_h = 0
|
self._current_h = 0
|
||||||
self.font = ImageFont.truetype(str(FONT_PATH / font), int(font_size))
|
self.font = ImageFont.truetype(str(FONT_PATH / font), int(font_size))
|
||||||
if not plain_text and not color:
|
if not plain_text and not color:
|
||||||
color = (255, 255, 255)
|
color = (255, 255, 255)
|
||||||
@ -287,11 +287,11 @@ class BuildImage:
|
|||||||
pos = (width, height)
|
pos = (width, height)
|
||||||
if isinstance(img, BuildImage):
|
if isinstance(img, BuildImage):
|
||||||
img = img.markImg
|
img = img.markImg
|
||||||
if self.current_w == self.w:
|
if self._current_w >= self.w:
|
||||||
self.current_w = 0
|
self._current_w = 0
|
||||||
self.current_h += self.paste_image_height
|
self._current_h += self.paste_image_height
|
||||||
if not pos:
|
if not pos:
|
||||||
pos = (self.current_w, self.current_h)
|
pos = (self._current_w, self._current_h)
|
||||||
if alpha:
|
if alpha:
|
||||||
try:
|
try:
|
||||||
self.markImg.paste(img, pos, img)
|
self.markImg.paste(img, pos, img)
|
||||||
@ -300,7 +300,7 @@ class BuildImage:
|
|||||||
self.markImg.paste(img, pos, img)
|
self.markImg.paste(img, pos, img)
|
||||||
else:
|
else:
|
||||||
self.markImg.paste(img, pos)
|
self.markImg.paste(img, pos)
|
||||||
self.current_w += self.paste_image_width
|
self._current_w += self.paste_image_width
|
||||||
|
|
||||||
def getsize(self, msg: str) -> Tuple[int, int]:
|
def getsize(self, msg: str) -> Tuple[int, int]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user