✨ 添加签到功能
🐛 修复默认使用格林威治时间而不是北京时间的BUG
This commit is contained in:
@@ -3,12 +3,16 @@ from pathlib import Path
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
|
||||
from . import config
|
||||
from .request import g_pRequestManager
|
||||
|
||||
|
||||
class CJsonManager:
|
||||
def __init__(self):
|
||||
self.m_pItem = {}
|
||||
self.m_pLevel = {}
|
||||
self.m_pSoil = {}
|
||||
self.m_pSign = {}
|
||||
|
||||
async def init(self) -> bool:
|
||||
if not await self.initItem():
|
||||
@@ -20,14 +24,17 @@ class CJsonManager:
|
||||
if not await self.initSoil():
|
||||
return False
|
||||
|
||||
return True
|
||||
if not await g_pRequestManager.initSignInFile():
|
||||
config.g_bSignStatus = False
|
||||
|
||||
return False
|
||||
else:
|
||||
return await self.initSign()
|
||||
|
||||
async def initItem(self) -> bool:
|
||||
current_file_path = Path(__file__)
|
||||
|
||||
try:
|
||||
with open(
|
||||
current_file_path.resolve().parent / "config/item.json",
|
||||
config.g_sConfigPath / "item.json",
|
||||
encoding="utf-8",
|
||||
) as file:
|
||||
self.m_pItem = json.load(file)
|
||||
@@ -41,11 +48,9 @@ class CJsonManager:
|
||||
return False
|
||||
|
||||
async def initLevel(self) -> bool:
|
||||
current_file_path = Path(__file__)
|
||||
|
||||
try:
|
||||
with open(
|
||||
current_file_path.resolve().parent / "config/level.json",
|
||||
config.g_sConfigPath / "level.json",
|
||||
encoding="utf-8",
|
||||
) as file:
|
||||
self.m_pLevel = json.load(file)
|
||||
@@ -59,11 +64,9 @@ class CJsonManager:
|
||||
return False
|
||||
|
||||
async def initSoil(self) -> bool:
|
||||
current_file_path = Path(__file__)
|
||||
|
||||
try:
|
||||
with open(
|
||||
current_file_path.resolve().parent / "config/soil.json",
|
||||
config.g_sConfigPath / "soil.json",
|
||||
encoding="utf-8",
|
||||
) as file:
|
||||
self.m_pSoil = json.load(file)
|
||||
@@ -76,4 +79,20 @@ class CJsonManager:
|
||||
logger.warning(f"soil.json JSON格式错误: {e}")
|
||||
return False
|
||||
|
||||
async def initSign(self) -> bool:
|
||||
try:
|
||||
with open(
|
||||
config.g_sSignInPath,
|
||||
encoding="utf-8",
|
||||
) as file:
|
||||
self.m_pSign = json.load(file)
|
||||
|
||||
return True
|
||||
except FileNotFoundError:
|
||||
logger.warning("sign_in.json 打开失败")
|
||||
return False
|
||||
except json.JSONDecodeError as e:
|
||||
logger.warning(f"sign_in.json JSON格式错误: {e}")
|
||||
return False
|
||||
|
||||
g_pJsonManager = CJsonManager()
|
||||
|
||||
Reference in New Issue
Block a user