mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-16 12:02:17 +00:00
14b107b5a1
Moves all subdirectories from 'simnet/client' to 'simnet/client/components' and adds the `__all__` variable to all affected files. This change is intended to improve code organization and make it easier to manage exported symbols from these modules.
28 lines
831 B
Python
28 lines
831 B
Python
from typing import Optional
|
|
|
|
from httpx import Cookies as _Cookies
|
|
|
|
__all__ = ("Cookies",)
|
|
|
|
|
|
class Cookies(_Cookies):
|
|
"""An extension of the `httpx.Cookies` class that includes additional functionality."""
|
|
|
|
COOKIE_USER_ID_NAMES = ("ltuid", "account_id", "ltuid_v2", "account_id_v2")
|
|
|
|
@property
|
|
def account_id(self) -> Optional[int]:
|
|
"""Return the user account ID if present in the cookies.
|
|
|
|
If one of the user ID cookies exists in the cookies, return its integer value.
|
|
Otherwise, return `None`.
|
|
|
|
Returns:
|
|
Optional[int]: The user account ID, or `None` if it is not present in the cookies.
|
|
"""
|
|
for name in self.COOKIE_USER_ID_NAMES:
|
|
value = self.get(name)
|
|
if value is not None:
|
|
return int(value)
|
|
return None
|