From 3087dd3085db2f6880ca5b803f64188308658479 Mon Sep 17 00:00:00 2001 From: Ching Date: Sun, 12 May 2024 11:23:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=88=98=E6=8A=A5?= =?UTF-8?q?=E4=B8=AD=E5=BC=80=E9=BB=91=E6=95=B0=E6=8D=AE=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E6=9C=89=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dota.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dota.py b/dota.py index 73b0b77..ec7a77e 100644 --- a/dota.py +++ b/dota.py @@ -139,11 +139,15 @@ class Friend(BaseModel): } for match_ in matches[:limit]: duration = '%d:%02d:%02d' % utils.convert_seconds_to_hms(match_['duration']) + if match_['party_size'] == None: + if Match.filter(match_id=match_['match_id']).exists(): + match_['party_size'] = Match.get(match_id=match_['match_id']).party_size + else: + match_['party_size'] = 0 + summary = f"{duration}" if match_['party_size'] and match_['party_size'] > 1: summary = f"{match_['party_size']}黑 {duration}" - elif match_['party_size'] == None: - summary = f"??黑 {duration}" - else: + elif match_['party_size'] and match_['party_size'] == 1: summary = f"单排 {duration}" if match_['average_rank']: @@ -228,10 +232,11 @@ def serialize_match_for_discord(match_): if Match.filter(match_id=match_['match_id']).exists(): match_['party_size'] = Match.get(match_id=match_['match_id']).party_size else: + match_['party_size'] = 0 summary = f"{match_['duration']}" if match_['party_size'] > 1: summary = f"{match_['party_size']}黑 {match_['duration']}" - else: + elif match_['party_size'] == 1: summary = f"单排 {match_['duration']}" radiant = []