From 33c5fbd2da866dea37d8ec48bad8b1ba54e5463a Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Fri, 17 Feb 2023 22:57:12 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E5=A4=9Abot?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=97=B6`=E6=B7=B1=E6=B8=8A=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1`=E5=92=8C`=E7=8C=9C=E8=AF=AD=E9=9F=B3`=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/Paimon_Abyss/abyss_statistics.py | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/LittlePaimon/plugins/Paimon_Abyss/abyss_statistics.py b/LittlePaimon/plugins/Paimon_Abyss/abyss_statistics.py index 8847bb7..67d01e6 100644 --- a/LittlePaimon/plugins/Paimon_Abyss/abyss_statistics.py +++ b/LittlePaimon/plugins/Paimon_Abyss/abyss_statistics.py @@ -37,25 +37,26 @@ async def get_group_avatar(group_id: str): async def get_statistics(group_id: int, bot: Bot): - now = datetime.datetime.now() - abyss_info_list = await AbyssInfo.filter( - total_battle__not=None, - total_star__not=None, - max_damage__not=None, - max_take_damage__not=None, - start_time__lte=now, - end_time__gte=now, - ) - if not abyss_info_list: + if not (info_list := await AbyssInfo.all()): return '本群还没有深渊战斗数据哦!' member_list = await bot.get_group_member_list(group_id=group_id) member_id_list = [str(member['user_id']) for member in member_list] - info_list = [info for info in abyss_info_list if info.user_id in member_id_list] - if not abyss_info_list: + 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 + ] + now = datetime.datetime.now().replace(tzinfo=pytz.timezone('Asia/Shanghai')) + info_list = [info for info in info_list if info.start_time <= now <= info.end_time] + if not info_list: return '本群还没有深渊战斗数据哦!' - elif len(abyss_info_list) < 3: + elif len(info_list) < 3: return '本群深渊有效战斗数据不足3人,无法生成统计图!' - for info in abyss_info_list: + for info in info_list: if info.nickname is None: for member in member_list: if info.user_id == str(member['user_id']):