2023-03-14 01:27:22 +00:00
|
|
|
from core.base_service import BaseService
|
2022-09-08 01:08:37 +00:00
|
|
|
from modules.wiki.character import Character
|
2023-04-26 08:48:05 +00:00
|
|
|
from modules.wiki.light_cone import LightCone
|
2024-03-28 14:44:32 +00:00
|
|
|
from modules.wiki.material import Material
|
2023-04-26 08:48:05 +00:00
|
|
|
from modules.wiki.raider import Raider
|
2024-03-28 14:44:32 +00:00
|
|
|
from modules.wiki.relic import Relic
|
2022-09-08 01:08:37 +00:00
|
|
|
from utils.log import logger
|
2022-07-26 10:07:31 +00:00
|
|
|
|
2023-03-14 01:27:22 +00:00
|
|
|
__all__ = ["WikiService"]
|
2022-07-26 10:07:31 +00:00
|
|
|
|
2023-03-14 01:27:22 +00:00
|
|
|
|
|
|
|
class WikiService(BaseService):
|
2023-04-26 08:48:05 +00:00
|
|
|
def __init__(self):
|
|
|
|
self.character = Character()
|
|
|
|
self.light_cone = LightCone()
|
2024-03-28 14:44:32 +00:00
|
|
|
self.material = Material()
|
2023-04-26 08:48:05 +00:00
|
|
|
self.raider = Raider()
|
2024-03-28 14:44:32 +00:00
|
|
|
self.relic = Relic()
|
2023-04-26 08:48:05 +00:00
|
|
|
|
|
|
|
async def initialize(self) -> None:
|
|
|
|
logger.info("正在加载 Wiki 数据")
|
2023-04-27 12:25:06 +00:00
|
|
|
try:
|
|
|
|
await self.character.read()
|
|
|
|
await self.light_cone.read()
|
2024-03-28 14:44:32 +00:00
|
|
|
await self.material.read()
|
2023-04-27 12:25:06 +00:00
|
|
|
await self.raider.read()
|
2024-03-28 14:44:32 +00:00
|
|
|
await self.relic.read()
|
2023-04-27 12:25:06 +00:00
|
|
|
except Exception as e:
|
|
|
|
logger.error("加载 Wiki 数据失败", exc_info=e)
|
2023-04-26 08:48:05 +00:00
|
|
|
logger.info("加载 Wiki 数据完成")
|
2022-07-26 10:07:31 +00:00
|
|
|
|
2023-08-29 06:03:21 +00:00
|
|
|
async def refresh_wiki(self) -> None:
|
2022-09-08 01:08:37 +00:00
|
|
|
logger.info("正在重新获取Wiki")
|
|
|
|
logger.info("正在重新获取角色信息")
|
2023-04-26 08:48:05 +00:00
|
|
|
await self.character.refresh()
|
|
|
|
logger.info("正在重新获取光锥信息")
|
|
|
|
await self.light_cone.refresh()
|
2024-03-28 14:44:32 +00:00
|
|
|
logger.info("正在重新获取材料信息")
|
|
|
|
await self.material.refresh()
|
2023-04-26 08:48:05 +00:00
|
|
|
logger.info("正在重新获取攻略信息")
|
|
|
|
await self.raider.refresh()
|
2024-03-28 14:44:32 +00:00
|
|
|
logger.info("正在重新获取遗器信息")
|
|
|
|
await self.relic.refresh()
|
2022-09-08 01:08:37 +00:00
|
|
|
logger.info("刷新成功")
|