From a4d7593ab0139009cba97f771f2d06419a2d0b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Sun, 11 Dec 2022 14:00:12 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Filter=20empty=20strings=20in=20?= =?UTF-8?q?parse=20cookies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/genshin/cookies.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/genshin/cookies.py b/plugins/genshin/cookies.py index fb7bd05..45fcfb8 100644 --- a/plugins/genshin/cookies.py +++ b/plugins/genshin/cookies.py @@ -264,12 +264,13 @@ class SetUserCookies(Plugin.Conversation, BasePlugin.Conversation): # cookie str to dict wrapped = ( ArkoWrapper(message.text.split(";")) + .filter(lambda x: x != "") .map(lambda x: x.strip()) .map(lambda x: ((y := x.split("="))[0], y[1])) ) cookie = {x[0]: x[1] for x in wrapped} cookies = self.parse_cookie(cookie) - except (AttributeError, ValueError) as exc: + except (AttributeError, ValueError, IndexError) as exc: logger.info("用户 %s[%s] Cookies解析出现错误\ntext:%s", user.full_name, user.id, message.text) logger.debug("解析Cookies出现错误", exc_info=exc) await message.reply_text("解析Cookies出现错误,请检查是否正确", reply_markup=ReplyKeyboardRemove())