🎨 Catch ValueError exception in input cookie

This commit is contained in:
洛水居室 2022-12-10 20:24:40 +08:00
parent ab793a07ce
commit 0ca5f0314e
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC

View File

@ -260,17 +260,17 @@ class SetUserCookies(Plugin.Conversation, BasePlugin.Conversation):
if message.text == "退出": if message.text == "退出":
await message.reply_text("退出任务", reply_markup=ReplyKeyboardRemove()) await message.reply_text("退出任务", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END return ConversationHandler.END
try:
# cookie str to dict # cookie str to dict
wrapped = ( wrapped = (
ArkoWrapper(message.text.split(";")).map(lambda x: x.strip()).map(lambda x: ((y := x.split("="))[0], y[1])) 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} cookie = {x[0]: x[1] for x in wrapped}
try:
cookies = self.parse_cookie(cookie) cookies = self.parse_cookie(cookie)
except (AttributeError, ValueError) as exc: 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) logger.debug("解析Cookies出现错误", exc_info=exc)
await message.reply_text("解析Cookies出现错误请检查是否正确", reply_markup=ReplyKeyboardRemove()) await message.reply_text("解析Cookies出现错误请检查是否正确", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END return ConversationHandler.END