🐛 修复上游 genshin.py 更新后导致的错误

* 🎨 初始化资源 `update_characters_enka`

* 🍱 替换 GitHub 地址为 FastGit 镜像源

* 🐛 修复上游未解析梦之树等级

Co-authored-by: xtaodada <xtao@xtaolink.cn>
This commit is contained in:
洛水居室 2022-10-06 12:38:02 +08:00 committed by GitHub
parent c51e7692f1
commit b1455be303
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

View File

@ -7,6 +7,7 @@ from multiprocessing import RLock as Lock
from pathlib import Path
from typing import Any, Callable, ClassVar, Dict, Iterator, List, NoReturn, Optional, TYPE_CHECKING, Type, TypeVar
import genshin
import pytz
from async_timeout import timeout
from telegram.error import NetworkError, TimedOut
@ -199,6 +200,19 @@ class Bot:
logger.exception(f"服务 \"{service.__class__.__name__}\" 关闭失败: \n{type(e).__name__}: {e}")
async def _post_init(self, context: CallbackContext) -> NoReturn:
logger.info('开始初始化 genshin.py 相关资源')
try:
# 替换为 fastgit 镜像源
for i in dir(genshin.utility.extdb):
if "_URL" in i:
setattr(genshin.utility.extdb, i,
getattr(genshin.utility.extdb, i).replace("githubusercontent.com", "fastgit.org"))
await genshin.utility.update_characters_enka()
except Exception as exc:
logger.error("初始化 genshin.py 相关资源失败")
logger.exception(exc)
else:
logger.success("初始化 genshin.py 相关资源成功")
self._services.update({CallbackContext: context})
logger.info('开始初始化服务')
await self.start_services()

View File

@ -78,11 +78,16 @@ class UserStatsPlugins(Plugin, BasePlugin):
}
for offering in exploration.offerings:
# 修复上游奇怪的问题
offering_name = offering.name
if isinstance(offering, dict):
offering_name = offering["name"]
offering_level = offering["level"]
else:
offering_name = offering.name
offering_level = offering.level
if offering_name == "Reputation":
offering_name = "声望等级"
offering_data = {
"data": f"{offering_name}{offering.level}"
"data": f"{offering_name}{offering_level}"
}
exploration_data["offerings"].append(offering_data)
user_data["world_exploration_list"].append(exploration_data)

View File

@ -1 +1,3 @@
from utils.patch import aiohttp
__all__ = ["aiohttp"]