From a3d10385a02d6d9c85975006ed38fd0a7dbbae55 Mon Sep 17 00:00:00 2001 From: newton_miku <1316561519@qq.com> Date: Sat, 31 Dec 2022 03:30:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Depic=E6=8A=A5=E9=94=99?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E7=AE=80=E4=BB=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.修复了因报错UnboundLocalError: local variable 'game_desp' referenced before assignment而导致的发送失败 2.修复因简介过长导致的win版QQ在群聊中无法查看发送的合并转发消息的问题(疑似因为单条消息过长?测试时安卓QQ无此异常)(当存在简短介绍时,使用简短介绍) --- plugins/epic/data_source.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/epic/data_source.py b/plugins/epic/data_source.py index 43389fac..f9b5f4ea 100755 --- a/plugins/epic/data_source.py +++ b/plugins/epic/data_source.py @@ -112,9 +112,15 @@ async def get_epic_free(bot: Bot, type_event: str): if pair["key"] == "publisherName": game_pub = pair["value"] if game.get("productSlug"): - gamesDesp = await get_epic_game_desp(game["productSlug"]) - #game_desp = game["description"] - game_desp = gamesDesp["description"] + gamesDesp = await get_epic_game_desp(game["productSlug"]) + try: + #是否存在简短的介绍 + if "shortDescription" in gamesDesp: + game_desp = gamesDesp["shortDescription"] + except KeyError: + game_desp = gamesDesp["description"] + else: + game_desp = game["description"] try: end_date_iso = game["promotions"]["promotionalOffers"][0][ "promotionalOffers" @@ -187,4 +193,4 @@ async def get_epic_free(bot: Bot, type_event: str): except TypeError as e: # logger.info(str(e)) pass - return msg_list, 200 \ No newline at end of file + return msg_list, 200