2023-02-06 15:05:21 +00:00
|
|
|
from typing import (
|
|
|
|
ClassVar
|
|
|
|
)
|
|
|
|
from .utils import get_user_agent
|
2023-02-16 18:05:15 +00:00
|
|
|
from .cache import Cache, StaticCache
|
2023-02-06 15:05:21 +00:00
|
|
|
|
|
|
|
class Config:
|
|
|
|
# HTTP Config
|
|
|
|
ENKA_PROTOCOL: ClassVar[str] = "https"
|
2023-02-07 08:22:05 +00:00
|
|
|
ENKA_URL: ClassVar[str] = "enka.network"
|
2023-02-06 15:05:21 +00:00
|
|
|
# Assets
|
|
|
|
ASSETS_PROTOCOL: ClassVar[str] = "https"
|
|
|
|
ASSETS_URL: ClassVar[str] = "raw.githubusercontent.com"
|
|
|
|
# Header Config
|
|
|
|
USER_AGENT: ClassVar[str] = get_user_agent()
|
|
|
|
# Client config
|
|
|
|
CACHE_ENABLED: ClassVar[bool] = True
|
2023-02-16 18:05:15 +00:00
|
|
|
CACHE: ClassVar[Cache] = StaticCache(1024, 60 * 3)
|
2023-02-06 15:05:21 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def init_cache(
|
|
|
|
cls,
|
|
|
|
cache: Cache,
|
|
|
|
enabled: bool = True
|
|
|
|
):
|
|
|
|
cls.CACHE = cache
|
|
|
|
cls.CACHE_ENABLED = enabled
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def init_user_agent(cls, agent: str):
|
|
|
|
cls.USER_AGENT = agent
|