🐛 修复一些因为时区非Asia/Shanghai导致的时间判断问题

This commit is contained in:
CMHopeSunshine 2022-10-01 09:47:56 +08:00
parent 71f3b5170c
commit 5290b0fc72
3 changed files with 7 additions and 7 deletions

View File

@ -82,13 +82,13 @@ async def check_note():
return return
if not subs: if not subs:
return return
logger.info('原神实时便签', f'开始执行定时检查,共<m>{len(subs)}</m>个任务,预计花费<m>{round(3 * len(subs) / 60, 2)}</m>分钟') logger.info('原神实时便签', f'开始执行定时检查,共<m>{len(subs)}</m>个任务,预计花费<m>{round(6 * len(subs) / 60, 2)}</m>分钟')
for sub in subs: for sub in subs:
limit_num = 5 if sub.resin_num and sub.coin_num else 3 limit_num = 5 if sub.resin_num and sub.coin_num else 3
if sub.today_remind_num <= limit_num and ( if sub.today_remind_num <= limit_num and (
sub.last_remind_time is None or (sub.last_remind_time is not None and ( sub.last_remind_time is None or (sub.last_remind_time is not None and (
sub.last_remind_time < (datetime.datetime.now() - datetime.timedelta(minutes=30)).replace( sub.last_remind_time + datetime.timedelta(minutes=30) <= datetime.datetime.now().replace(
tzinfo=pytz.timezone('Asia/Shanghai'))))): tzinfo=pytz.timezone('UTC'))))):
data = await get_mihoyo_private_data(sub.uid, str(sub.user_id), 'daily_note') data = await get_mihoyo_private_data(sub.uid, str(sub.user_id), 'daily_note')
if isinstance(data, str): if isinstance(data, str):
logger.info('原神实时便签', '', {'用户': sub.user_id, 'UID': sub.uid}, 'Cookie未绑定或已失效删除任务', False) logger.info('原神实时便签', '', {'用户': sub.user_id, 'UID': sub.uid}, 'Cookie未绑定或已失效删除任务', False)

View File

@ -34,7 +34,7 @@ async def get_statistics(group_id: int):
member_id_list = [str(member['user_id']) for member in member_list] member_id_list = [str(member['user_id']) for member in member_list]
info_list = [info for info in info_list if info_list = [info for info in info_list if
info.user_id in member_id_list and info.total_battle and info.total_star and info.max_damage and info.max_take_damage] info.user_id in member_id_list and info.total_battle and info.total_star and info.max_damage and info.max_take_damage]
now = datetime.datetime.now().replace(tzinfo=pytz.timezone('Asia/Shanghai')) now = datetime.datetime.now().replace(tzinfo=pytz.timezone('UTC'))
info_list = [info for info in info_list if info.start_time <= now <= info.end_time] info_list = [info for info in info_list if info.start_time <= now <= info.end_time]
if not info_list: if not info_list:
return '本群还没有深渊战斗数据哦!' return '本群还没有深渊战斗数据哦!'

View File

@ -170,7 +170,7 @@ class GenshinInfoManager:
"""如果角色不存在或者角色的更新时间在6小时前则更新角色信息""" """如果角色不存在或者角色的更新时间在6小时前则更新角色信息"""
character = await Character.get_or_none(**query, data_source='enka') character = await Character.get_or_none(**query, data_source='enka')
if not character or character.update_time < (datetime.datetime.now() - datetime.timedelta(hours=pm.config.ysd_auto_update)).replace( if not character or character.update_time < (datetime.datetime.now() - datetime.timedelta(hours=pm.config.ysd_auto_update)).replace(
tzinfo=pytz.timezone('Asia/Shanghai')): tzinfo=pytz.timezone('UTC')):
await self.update_from_enka() await self.update_from_enka()
if character := await Character.get_or_none(**query, data_source='enka'): if character := await Character.get_or_none(**query, data_source='enka'):
logger.info('原神角色面板', '➤➤', {'角色': name or character_id}, '数据更新成功', True) logger.info('原神角色面板', '➤➤', {'角色': name or character_id}, '数据更新成功', True)
@ -194,7 +194,7 @@ class GenshinInfoManager:
player_info = await PlayerInfo.get_or_none(user_id=self.user_id, uid=self.uid) player_info = await PlayerInfo.get_or_none(user_id=self.user_id, uid=self.uid)
if player_info is None or player_info.update_time is None or player_info.update_time < ( if player_info is None or player_info.update_time is None or player_info.update_time < (
datetime.datetime.now() - datetime.timedelta(hours=pm.config.ysa_auto_update)).replace( datetime.datetime.now() - datetime.timedelta(hours=pm.config.ysa_auto_update)).replace(
tzinfo=pytz.timezone('Asia/Shanghai')): tzinfo=pytz.timezone('UTC')):
result = await self.update_from_mihoyo() result = await self.update_from_mihoyo()
if result != '更新成功': if result != '更新成功':
return result, [] return result, []
@ -211,7 +211,7 @@ class GenshinInfoManager:
player_info = await PlayerInfo.get_or_none(user_id=self.user_id, uid=self.uid) player_info = await PlayerInfo.get_or_none(user_id=self.user_id, uid=self.uid)
if player_info is None or player_info.update_time is None or player_info.update_time < ( if player_info is None or player_info.update_time is None or player_info.update_time < (
datetime.datetime.now() - datetime.timedelta(hours=pm.config.ys_auto_update)).replace( datetime.datetime.now() - datetime.timedelta(hours=pm.config.ys_auto_update)).replace(
tzinfo=pytz.timezone('Asia/Shanghai')): tzinfo=pytz.timezone('UTC')):
result = await self.update_from_mihoyo() result = await self.update_from_mihoyo()
if result != '更新成功': if result != '更新成功':
return result, None return result, None