mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-02 10:10:01 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7368c83bc | ||
|
|
4011620da1 | ||
|
|
6e0b91531e | ||
|
|
b8ca1d68aa | ||
|
|
2b9cda40a0 |
@@ -236,13 +236,15 @@ __Docker 最新版本由 [Sakuracio](https://github.com/Sakuracio) 提供__
|
|||||||
|
|
||||||
## 更新
|
## 更新
|
||||||
|
|
||||||
### 2022/2/19 \[v0.1.2] (nonebot beta2!)
|
### 2022/2/19 \[v0.1.3] (nonebot beta2!)
|
||||||
|
|
||||||
* 适配nonebot.beta2
|
* 适配nonebot.beta2
|
||||||
* 删除图片搜索 nonebot_plugin_picsearcher
|
* 删除图片搜索 nonebot_plugin_picsearcher
|
||||||
* 新增图片搜索 search_image
|
* 新增图片搜索 search_image
|
||||||
* 替换cos api
|
* 替换cos api
|
||||||
* 原神签到树脂提醒新增绑定群里,在某群绑定uid就会在某群发送提醒信息(有好友则私聊,需要重新绑定uid
|
* 原神签到树脂提醒新增绑定群里,在某群绑定uid就会在某群发送提醒信息(有好友则私聊,需要重新绑定uid
|
||||||
|
* 修改update_info.json
|
||||||
|
* 修复原神资源查询下载数据失败时导致报错
|
||||||
* 优化BuildImage.circle()锯齿问题 [@pull/109](https://github.com/HibiKier/zhenxun_bot/pull/109)
|
* 优化BuildImage.circle()锯齿问题 [@pull/109](https://github.com/HibiKier/zhenxun_bot/pull/109)
|
||||||
* epic restful 替换 [@pull/119](https://github.com/HibiKier/zhenxun_bot/pull/119)
|
* epic restful 替换 [@pull/119](https://github.com/HibiKier/zhenxun_bot/pull/119)
|
||||||
* fix: 修复远古时期残留的epic推送问题 [@pull/122](https://github.com/HibiKier/zhenxun_bot/pull/122)
|
* fix: 修复远古时期残留的epic推送问题 [@pull/122](https://github.com/HibiKier/zhenxun_bot/pull/122)
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
__version__: v0.1.2
|
__version__: v0.1.3
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ async def query_resource(resource_name: str) -> str:
|
|||||||
planning_route = True
|
planning_route = True
|
||||||
if not resource_name or resource_name not in resource_name_list:
|
if not resource_name or resource_name not in resource_name_list:
|
||||||
# return f"未查找到 {resource_name} 资源,可通过 “原神资源列表” 获取全部资源名称.."
|
# return f"未查找到 {resource_name} 资源,可通过 “原神资源列表” 获取全部资源名称.."
|
||||||
return ''
|
return ""
|
||||||
map_ = Map(
|
map_ = Map(
|
||||||
resource_name, CENTER_POINT, planning_route=planning_route, ratio=MAP_RATIO
|
resource_name, CENTER_POINT, planning_route=planning_route, ratio=MAP_RATIO
|
||||||
)
|
)
|
||||||
@@ -84,7 +84,7 @@ def check_resource_exists(resource: str) -> bool:
|
|||||||
检查资源是否存在
|
检查资源是否存在
|
||||||
:param resource: 资源名称
|
:param resource: 资源名称
|
||||||
"""
|
"""
|
||||||
resource = resource.replace('路径', '').replace('路线', '')
|
resource = resource.replace("路径", "").replace("路线", "")
|
||||||
return resource in resource_name_list
|
return resource in resource_name_list
|
||||||
|
|
||||||
|
|
||||||
@@ -97,16 +97,18 @@ async def init(flag: bool = False):
|
|||||||
await download_resource_data(semaphore)
|
await download_resource_data(semaphore)
|
||||||
await download_resource_type()
|
await download_resource_type()
|
||||||
if not CENTER_POINT:
|
if not CENTER_POINT:
|
||||||
CENTER_POINT = json.load(open(resource_label_file, "r", encoding="utf8"))[
|
if resource_label_file.exists():
|
||||||
"CENTER_POINT"
|
CENTER_POINT = json.load(
|
||||||
]
|
open(resource_label_file, "r", encoding="utf8")
|
||||||
with open(resource_type_file, "r", encoding="utf8") as f:
|
)["CENTER_POINT"]
|
||||||
data = json.load(f)
|
if resource_label_file.exists():
|
||||||
for id_ in data:
|
with open(resource_type_file, "r", encoding="utf8") as f:
|
||||||
for x in data[id_]["children"]:
|
data = json.load(f)
|
||||||
resource_name_list.append(x["name"])
|
for id_ in data:
|
||||||
|
for x in data[id_]["children"]:
|
||||||
|
resource_name_list.append(x["name"])
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
logger.warning('原神资源查询信息初始化超时....')
|
logger.warning("原神资源查询信息初始化超时....")
|
||||||
|
|
||||||
|
|
||||||
# 图标及位置资源
|
# 图标及位置资源
|
||||||
@@ -114,7 +116,7 @@ async def download_resource_data(semaphore: Semaphore):
|
|||||||
icon_path.mkdir(parents=True, exist_ok=True)
|
icon_path.mkdir(parents=True, exist_ok=True)
|
||||||
resource_label_file.parent.mkdir(parents=True, exist_ok=True)
|
resource_label_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
try:
|
try:
|
||||||
response = await AsyncHttpx.get(POINT_LIST_URL, timeout=5)
|
response = await AsyncHttpx.get(POINT_LIST_URL, timeout=10)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
if data["message"] == "OK":
|
if data["message"] == "OK":
|
||||||
@@ -157,16 +159,14 @@ async def download_resource_data(semaphore: Semaphore):
|
|||||||
|
|
||||||
|
|
||||||
# 下载原神地图并拼图
|
# 下载原神地图并拼图
|
||||||
async def download_map_init(
|
async def download_map_init(semaphore: Semaphore, flag: bool = False):
|
||||||
semaphore: Semaphore, flag: bool = False
|
|
||||||
):
|
|
||||||
global CENTER_POINT, MAP_RATIO
|
global CENTER_POINT, MAP_RATIO
|
||||||
map_path.mkdir(exist_ok=True, parents=True)
|
map_path.mkdir(exist_ok=True, parents=True)
|
||||||
_map = map_path / "map.png"
|
_map = map_path / "map.png"
|
||||||
if _map.exists() and os.path.getsize(_map) > 1024 * 1024 * 30:
|
if _map.exists() and os.path.getsize(_map) > 1024 * 1024 * 30:
|
||||||
_map.unlink()
|
_map.unlink()
|
||||||
try:
|
try:
|
||||||
response = await AsyncHttpx.get(MAP_URL, timeout=5)
|
response = await AsyncHttpx.get(MAP_URL, timeout=10)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
if data["message"] == "OK":
|
if data["message"] == "OK":
|
||||||
@@ -176,20 +176,24 @@ async def download_map_init(
|
|||||||
data = data["slices"]
|
data = data["slices"]
|
||||||
idx = 0
|
idx = 0
|
||||||
for _map_data in data[0]:
|
for _map_data in data[0]:
|
||||||
map_url = _map_data['url']
|
map_url = _map_data["url"]
|
||||||
await download_image(
|
await download_image(
|
||||||
map_url,
|
map_url,
|
||||||
f"{map_path}/{idx}.png",
|
f"{map_path}/{idx}.png",
|
||||||
semaphore,
|
semaphore,
|
||||||
force_flag=flag,
|
force_flag=flag,
|
||||||
)
|
)
|
||||||
BuildImage(0, 0, background=f"{map_path}/{idx}.png", ratio=MAP_RATIO).save()
|
BuildImage(
|
||||||
|
0, 0, background=f"{map_path}/{idx}.png", ratio=MAP_RATIO
|
||||||
|
).save()
|
||||||
idx += 1
|
idx += 1
|
||||||
_w, h = BuildImage(0, 0, background=f"{map_path}/0.png").size
|
_w, h = BuildImage(0, 0, background=f"{map_path}/0.png").size
|
||||||
w = _w * len(os.listdir(map_path))
|
w = _w * len(os.listdir(map_path))
|
||||||
map_file = BuildImage(w, h, _w, h, ratio=MAP_RATIO)
|
map_file = BuildImage(w, h, _w, h, ratio=MAP_RATIO)
|
||||||
for i in range(idx):
|
for i in range(idx):
|
||||||
map_file.paste(BuildImage(0, 0, background=f"{map_path}/{i}.png"))
|
map_file.paste(
|
||||||
|
BuildImage(0, 0, background=f"{map_path}/{i}.png")
|
||||||
|
)
|
||||||
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"]}')
|
||||||
@@ -205,7 +209,7 @@ async def download_map_init(
|
|||||||
async def download_resource_type():
|
async def download_resource_type():
|
||||||
resource_type_file.parent.mkdir(parents=True, exist_ok=True)
|
resource_type_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
try:
|
try:
|
||||||
response = await AsyncHttpx.get(LABEL_URL, timeout=5)
|
response = await AsyncHttpx.get(LABEL_URL, timeout=10)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
if data["message"] == "OK":
|
if data["message"] == "OK":
|
||||||
@@ -251,7 +255,7 @@ async def download_image(
|
|||||||
async with semaphore:
|
async with semaphore:
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(path) or not is_valid or force_flag:
|
if not os.path.exists(path) or not is_valid or force_flag:
|
||||||
if await AsyncHttpx.download_file(img_url, path, timeout=5):
|
if await AsyncHttpx.download_file(img_url, path, timeout=10):
|
||||||
logger.info(f"下载原神资源图标:{img_url}")
|
logger.info(f"下载原神资源图标:{img_url}")
|
||||||
if gen_flag:
|
if gen_flag:
|
||||||
gen_icon(path)
|
gen_icon(path)
|
||||||
|
|||||||
+1
-1
@@ -9,6 +9,6 @@
|
|||||||
"configs/utils",
|
"configs/utils",
|
||||||
"bot.py"
|
"bot.py"
|
||||||
],
|
],
|
||||||
"add_file": [],
|
"add_file": ["poetry.lock", "pyproject.toml"],
|
||||||
"delete_file": []
|
"delete_file": []
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user