mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2024-11-16 04:45:27 +00:00
🐛 修复上游 genshin.py
更新后导致的错误
* 🎨 初始化资源 `update_characters_enka` * 🍱 替换 GitHub 地址为 FastGit 镜像源 * 🐛 修复上游未解析梦之树等级 Co-authored-by: xtaodada <xtao@xtaolink.cn>
This commit is contained in:
parent
c51e7692f1
commit
b1455be303
14
core/bot.py
14
core/bot.py
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -1 +1,3 @@
|
||||
from utils.patch import aiohttp
|
||||
|
||||
__all__ = ["aiohttp"]
|
||||
|
Loading…
Reference in New Issue
Block a user