From 0ca5f0314e114ad5a37b84f5fc1a35936863deda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Sat, 10 Dec 2022 20:24:40 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Catch=20`ValueError`=20exception?= =?UTF-8?q?=20in=20input=20cookie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/genshin/cookies.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/genshin/cookies.py b/plugins/genshin/cookies.py index a2f9b9c..f35f97c 100644 --- a/plugins/genshin/cookies.py +++ b/plugins/genshin/cookies.py @@ -260,17 +260,17 @@ class SetUserCookies(Plugin.Conversation, BasePlugin.Conversation): if message.text == "退出": await message.reply_text("退出任务", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END - - # cookie str to dict - wrapped = ( - ArkoWrapper(message.text.split(";")).map(lambda x: x.strip()).map(lambda x: ((y := x.split("="))[0], y[1])) - ) - cookie = {x[0]: x[1] for x in wrapped} - try: + # cookie str to dict + wrapped = ( + ArkoWrapper(message.text.split(";")) + .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: - logger.info("用户 %s[%s] Cookies解析出现错误", user.full_name, user.id) + 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()) return ConversationHandler.END