From 01e3c236518cdef6c68cb35a0eb2d911518e4e56 Mon Sep 17 00:00:00 2001 From: Ching Date: Tue, 3 Oct 2023 23:11:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(dota.py):=20=E4=BF=AE=E5=A4=8D=20party=5Fsi?= =?UTF-8?q?ze=20=E4=B8=BA=20None=20=E6=97=B6=E5=BA=8F=E5=88=97=E5=8C=96?= =?UTF-8?q?=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 修复 party_size 为 None 时序列化报错的问题 Signed-off-by: Ching --- dota.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dota.py b/dota.py index 9795472..85a2e9f 100644 --- a/dota.py +++ b/dota.py @@ -213,7 +213,9 @@ def serialize_match_for_discord(match_): is_radiant = player['is_radiant'] break win = is_radiant == match_['radiant_win'] - if match_['party_size'] > 1: + if not match_['party_size']: + summary = f"??黑 {match_['duration']}" + elif match_['party_size'] > 1: summary = f"{match_['party_size']}黑 {match_['duration']}" else: summary = f"单排 {match_['duration']}"