🎨 Filter empty strings in parse cookies

This commit is contained in:
洛水居室 2022-12-11 14:00:12 +08:00
parent cf22949a81
commit a4d7593ab0
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC

View File

@ -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())