mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2025-01-30 14:58:42 +00:00
🐛 Ensure cookie uid IntStr is int
This commit is contained in:
parent
409f0648fd
commit
2e9ea3e87b
@ -1,8 +1,15 @@
|
||||
from typing import Optional, TypeVar
|
||||
from typing import Optional, Annotated, Union
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, BeforeValidator
|
||||
|
||||
IntStr = TypeVar("IntStr", int, str)
|
||||
|
||||
def int_str_check(value: Union[int, str]) -> Union[int, str]:
|
||||
if value is not None:
|
||||
int(value)
|
||||
return value
|
||||
|
||||
|
||||
IntStr = Annotated[Union[int, str], BeforeValidator(int_str_check)]
|
||||
|
||||
__all__ = ("CookiesModel",)
|
||||
|
||||
|
@ -205,6 +205,8 @@ class AccountCookiesPlugin(Plugin.Conversation):
|
||||
)
|
||||
cookie = {x[0]: x[1] for x in wrapped}
|
||||
cookies = self.parse_cookie(cookie)
|
||||
if cookies:
|
||||
CookiesModel.model_validate(cookies)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user