🎨 Update parse_cookie

This commit is contained in:
洛水居室 2023-02-21 22:34:53 +08:00
parent 9efea3f398
commit b258deb864
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC

View File

@ -47,20 +47,12 @@ class SetUserCookies(Plugin.Conversation, BasePlugin.Conversation):
def parse_cookie(cookie: Dict[str, str]) -> Dict[str, str]: def parse_cookie(cookie: Dict[str, str]) -> Dict[str, str]:
cookies = {} cookies = {}
v1_keys = ["ltoken", "ltuid", "login_uid", "cookie_token"] v1_keys = ["ltoken", "ltuid", "account_id", "cookie_token", "stoken", "stuid", "login_uid", "login_ticket"]
v2_keys = ["ltoken_v2", "ltmid_v2", "account_mid_v2", "cookie_token_v2", "login_ticket", "stoken"] v2_keys = ["ltoken_v2", "ltmid_v2", "ltuid_v2", "account_mid_v2", "cookie_token_v2", "account_id_v2"]
cookie_is_v1 = None
for k in v1_keys + v2_keys: for k in v1_keys + v2_keys:
v = cookie.get(k)
if v is not None and cookie_is_v1 is None:
cookie_is_v1 = k not in v2_keys
cookies[k] = cookie.get(k) cookies[k] = cookie.get(k)
if cookie_is_v1:
cookies["account_id"] = cookies["ltuid"]
return {k: v for k, v in cookies.items() if v is not None} return {k: v for k, v in cookies.items() if v is not None}
@conversation.entry_point @conversation.entry_point