Module genshin.client.components.teapot

Teapot component.

Classes

class TeapotClient (cookies: ForwardRef('http.cookies.BaseCookie[Any]') | Mapping[Any, Any] | str | Sequence[ForwardRef('http.cookies.BaseCookie[Any]') | Mapping[Any, Any] | str] | None = None,
*,
authkey: str | None = None,
lang: str = 'en-us',
region: Region = Region.OVERSEAS,
proxy: str | None = None,
game: Game | None = None,
uid: int | None = None,
hoyolab_id: int | None = None,
device_id: str | None = None,
device_fp: str | None = None,
headers: Mapping[str, str] | Mapping[multidict._multidict.istr, str] | multidict._multidict.CIMultiDict | multidict._multidict.CIMultiDictProxy | Iterable[Tuple[str | multidict._multidict.istr, str]] | None = None,
cache: BaseCache | None = None,
debug: bool = False)
Expand source code
class TeapotClient(base.BaseClient):
    """teapot component."""

    async def request_teapot(
        self,
        endpoint: str,
        *,
        method: str = "GET",
        lang: typing.Optional[str] = None,
        params: typing.Optional[typing.Mapping[str, typing.Any]] = None,
        **kwargs: typing.Any,
    ) -> typing.Mapping[str, typing.Any]:
        """Make a request towards the teapot endpoint."""
        params = dict(params or {})

        base_url = routes.TEAPOT_URL.get_url(self.region)
        url = base_url / endpoint

        params["lang"] = lang or self.lang

        return await self.request(url, method=method, params=params, **kwargs)

    async def _get_teapot_replica_page(
        self,
        page: int,
        *,
        zip_type: int = 1,
        block_id: typing.Optional[str] = None,
        module_id: typing.Optional[str] = None,
        region: typing.Optional[str] = None,
        version: typing.Optional[str] = None,
        limit: int = 20,
        lang: typing.Optional[str] = None,
    ) -> typing.Sequence[models.TeapotReplica]:
        """Get a teapot replica page."""
        params = dict(
            next=page * limit,  # weirdest sorting ever
            zip_type=zip_type,
            block_id=block_id or "",
            module_id=module_id or "",
            target_region=region or "",
            version=version or "",
            limit=limit,
        )
        data = await self.request_teapot("list", lang=lang, params=params)
        return [models.TeapotReplica(**entry) for entry in data["articles"]]

    def teapot_replicas(
        self,
        *,
        limit: typing.Optional[int] = None,
        zip_type: int = 1,
        block_id: typing.Optional[str] = None,
        module_id: typing.Optional[str] = None,
        region: typing.Optional[str] = None,
        uid: typing.Optional[int] = None,
        version: typing.Optional[str] = None,
        page_size: int = 20,
        lang: typing.Optional[str] = None,
    ) -> paginators.PagedPaginator[models.TeapotReplica]:
        """Get a teapot replica paginator."""
        if not region and uid:
            region = utility.recognize_genshin_server(uid)

        return paginators.PagedPaginator(
            functools.partial(
                self._get_teapot_replica_page,
                zip_type=zip_type,
                block_id=block_id,
                module_id=module_id,
                region=region,
                version=version,
                limit=page_size,
                lang=lang,
            ),
            limit=limit,
            page_size=page_size,
        )

teapot component.

Ancestors

Subclasses

Class variables

var logger : logging.Logger

Instance variables

var authkeys : dict[Game, str]
Expand source code
class TeapotClient(base.BaseClient):
    """teapot component."""

    async def request_teapot(
        self,
        endpoint: str,
        *,
        method: str = "GET",
        lang: typing.Optional[str] = None,
        params: typing.Optional[typing.Mapping[str, typing.Any]] = None,
        **kwargs: typing.Any,
    ) -> typing.Mapping[str, typing.Any]:
        """Make a request towards the teapot endpoint."""
        params = dict(params or {})

        base_url = routes.TEAPOT_URL.get_url(self.region)
        url = base_url / endpoint

        params["lang"] = lang or self.lang

        return await self.request(url, method=method, params=params, **kwargs)

    async def _get_teapot_replica_page(
        self,
        page: int,
        *,
        zip_type: int = 1,
        block_id: typing.Optional[str] = None,
        module_id: typing.Optional[str] = None,
        region: typing.Optional[str] = None,
        version: typing.Optional[str] = None,
        limit: int = 20,
        lang: typing.Optional[str] = None,
    ) -> typing.Sequence[models.TeapotReplica]:
        """Get a teapot replica page."""
        params = dict(
            next=page * limit,  # weirdest sorting ever
            zip_type=zip_type,
            block_id=block_id or "",
            module_id=module_id or "",
            target_region=region or "",
            version=version or "",
            limit=limit,
        )
        data = await self.request_teapot("list", lang=lang, params=params)
        return [models.TeapotReplica(**entry) for entry in data["articles"]]

    def teapot_replicas(
        self,
        *,
        limit: typing.Optional[int] = None,
        zip_type: int = 1,
        block_id: typing.Optional[str] = None,
        module_id: typing.Optional[str] = None,
        region: typing.Optional[str] = None,
        uid: typing.Optional[int] = None,
        version: typing.Optional[str] = None,
        page_size: int = 20,
        lang: typing.Optional[str] = None,
    ) -> paginators.PagedPaginator[models.TeapotReplica]:
        """Get a teapot replica paginator."""
        if not region and uid:
            region = utility.recognize_genshin_server(uid)

        return paginators.PagedPaginator(
            functools.partial(
                self._get_teapot_replica_page,
                zip_type=zip_type,
                block_id=block_id,
                module_id=module_id,
                region=region,
                version=version,
                limit=page_size,
                lang=lang,
            ),
            limit=limit,
            page_size=page_size,
        )
var cacheBaseCache
Expand source code
class TeapotClient(base.BaseClient):
    """teapot component."""

    async def request_teapot(
        self,
        endpoint: str,
        *,
        method: str = "GET",
        lang: typing.Optional[str] = None,
        params: typing.Optional[typing.Mapping[str, typing.Any]] = None,
        **kwargs: typing.Any,
    ) -> typing.Mapping[str, typing.Any]:
        """Make a request towards the teapot endpoint."""
        params = dict(params or {})

        base_url = routes.TEAPOT_URL.get_url(self.region)
        url = base_url / endpoint

        params["lang"] = lang or self.lang

        return await self.request(url, method=method, params=params, **kwargs)

    async def _get_teapot_replica_page(
        self,
        page: int,
        *,
        zip_type: int = 1,
        block_id: typing.Optional[str] = None,
        module_id: typing.Optional[str] = None,
        region: typing.Optional[str] = None,
        version: typing.Optional[str] = None,
        limit: int = 20,
        lang: typing.Optional[str] = None,
    ) -> typing.Sequence[models.TeapotReplica]:
        """Get a teapot replica page."""
        params = dict(
            next=page * limit,  # weirdest sorting ever
            zip_type=zip_type,
            block_id=block_id or "",
            module_id=module_id or "",
            target_region=region or "",
            version=version or "",
            limit=limit,
        )
        data = await self.request_teapot("list", lang=lang, params=params)
        return [models.TeapotReplica(**entry) for entry in data["articles"]]

    def teapot_replicas(
        self,
        *,
        limit: typing.Optional[int] = None,
        zip_type: int = 1,
        block_id: typing.Optional[str] = None,
        module_id: typing.Optional[str] = None,
        region: typing.Optional[str] = None,
        uid: typing.Optional[int] = None,
        version: typing.Optional[str] = None,
        page_size: int = 20,
        lang: typing.Optional[str] = None,
    ) -> paginators.PagedPaginator[models.TeapotReplica]:
        """Get a teapot replica paginator."""
        if not region and uid:
            region = utility.recognize_genshin_server(uid)

        return paginators.PagedPaginator(
            functools.partial(
                self._get_teapot_replica_page,
                zip_type=zip_type,
                block_id=block_id,
                module_id=module_id,
                region=region,
                version=version,
                limit=page_size,
                lang=lang,
            ),
            limit=limit,
            page_size=page_size,
        )
var cookie_managerBaseCookieManager
Expand source code
class TeapotClient(base.BaseClient):
    """teapot component."""

    async def request_teapot(
        self,
        endpoint: str,
        *,
        method: str = "GET",
        lang: typing.Optional[str] = None,
        params: typing.Optional[typing.Mapping[str, typing.Any]] = None,
        **kwargs: typing.Any,
    ) -> typing.Mapping[str, typing.Any]:
        """Make a request towards the teapot endpoint."""
        params = dict(params or {})

        base_url = routes.TEAPOT_URL.get_url(self.region)
        url = base_url / endpoint

        params["lang"] = lang or self.lang

        return await self.request(url, method=method, params=params, **kwargs)

    async def _get_teapot_replica_page(
        self,
        page: int,
        *,
        zip_type: int = 1,
        block_id: typing.Optional[str] = None,
        module_id: typing.Optional[str] = None,
        region: typing.Optional[str] = None,
        version: typing.Optional[str] = None,
        limit: int = 20,
        lang: typing.Optional[str] = None,
    ) -> typing.Sequence[models.TeapotReplica]:
        """Get a teapot replica page."""
        params = dict(
            next=page * limit,  # weirdest sorting ever
            zip_type=zip_type,
            block_id=block_id or "",
            module_id=module_id or "",
            target_region=region or "",
            version=version or "",
            limit=limit,
        )
        data = await self.request_teapot("list", lang=lang, params=params)
        return [models.TeapotReplica(**entry) for entry in data["articles"]]

    def teapot_replicas(
        self,
        *,
        limit: typing.Optional[int] = None,
        zip_type: int = 1,
        block_id: typing.Optional[str] = None,
        module_id: typing.Optional[str] = None,
        region: typing.Optional[str] = None,
        uid: typing.Optional[int] = None,
        version: typing.Optional[str] = None,
        page_size: int = 20,
        lang: typing.Optional[str] = None,
    ) -> paginators.PagedPaginator[models.TeapotReplica]:
        """Get a teapot replica paginator."""
        if not region and uid:
            region = utility.recognize_genshin_server(uid)

        return paginators.PagedPaginator(
            functools.partial(
                self._get_teapot_replica_page,
                zip_type=zip_type,
                block_id=block_id,
                module_id=module_id,
                region=region,
                version=version,
                limit=page_size,
                lang=lang,
            ),
            limit=limit,
            page_size=page_size,
        )
var custom_headers : multidict._multidict.CIMultiDict[str]
Expand source code
class TeapotClient(base.BaseClient):
    """teapot component."""

    async def request_teapot(
        self,
        endpoint: str,
        *,
        method: str = "GET",
        lang: typing.Optional[str] = None,
        params: typing.Optional[typing.Mapping[str, typing.Any]] = None,
        **kwargs: typing.Any,
    ) -> typing.Mapping[str, typing.Any]:
        """Make a request towards the teapot endpoint."""
        params = dict(params or {})

        base_url = routes.TEAPOT_URL.get_url(self.region)
        url = base_url / endpoint

        params["lang"] = lang or self.lang

        return await self.request(url, method=method, params=params, **kwargs)

    async def _get_teapot_replica_page(
        self,
        page: int,
        *,
        zip_type: int = 1,
        block_id: typing.Optional[str] = None,
        module_id: typing.Optional[str] = None,
        region: typing.Optional[str] = None,
        version: typing.Optional[str] = None,
        limit: int = 20,
        lang: typing.Optional[str] = None,
    ) -> typing.Sequence[models.TeapotReplica]:
        """Get a teapot replica page."""
        params = dict(
            next=page * limit,  # weirdest sorting ever
            zip_type=zip_type,
            block_id=block_id or "",
            module_id=module_id or "",
            target_region=region or "",
            version=version or "",
            limit=limit,
        )
        data = await self.request_teapot("list", lang=lang, params=params)
        return [models.TeapotReplica(**entry) for entry in data["articles"]]

    def teapot_replicas(
        self,
        *,
        limit: typing.Optional[int] = None,
        zip_type: int = 1,
        block_id: typing.Optional[str] = None,
        module_id: typing.Optional[str] = None,
        region: typing.Optional[str] = None,
        uid: typing.Optional[int] = None,
        version: typing.Optional[str] = None,
        page_size: int = 20,
        lang: typing.Optional[str] = None,
    ) -> paginators.PagedPaginator[models.TeapotReplica]:
        """Get a teapot replica paginator."""
        if not region and uid:
            region = utility.recognize_genshin_server(uid)

        return paginators.PagedPaginator(
            functools.partial(
                self._get_teapot_replica_page,
                zip_type=zip_type,
                block_id=block_id,
                module_id=module_id,
                region=region,
                version=version,
                limit=page_size,
                lang=lang,
            ),
            limit=limit,
            page_size=page_size,
        )
var uids : dict[Game, int]
Expand source code
class TeapotClient(base.BaseClient):
    """teapot component."""

    async def request_teapot(
        self,
        endpoint: str,
        *,
        method: str = "GET",
        lang: typing.Optional[str] = None,
        params: typing.Optional[typing.Mapping[str, typing.Any]] = None,
        **kwargs: typing.Any,
    ) -> typing.Mapping[str, typing.Any]:
        """Make a request towards the teapot endpoint."""
        params = dict(params or {})

        base_url = routes.TEAPOT_URL.get_url(self.region)
        url = base_url / endpoint

        params["lang"] = lang or self.lang

        return await self.request(url, method=method, params=params, **kwargs)

    async def _get_teapot_replica_page(
        self,
        page: int,
        *,
        zip_type: int = 1,
        block_id: typing.Optional[str] = None,
        module_id: typing.Optional[str] = None,
        region: typing.Optional[str] = None,
        version: typing.Optional[str] = None,
        limit: int = 20,
        lang: typing.Optional[str] = None,
    ) -> typing.Sequence[models.TeapotReplica]:
        """Get a teapot replica page."""
        params = dict(
            next=page * limit,  # weirdest sorting ever
            zip_type=zip_type,
            block_id=block_id or "",
            module_id=module_id or "",
            target_region=region or "",
            version=version or "",
            limit=limit,
        )
        data = await self.request_teapot("list", lang=lang, params=params)
        return [models.TeapotReplica(**entry) for entry in data["articles"]]

    def teapot_replicas(
        self,
        *,
        limit: typing.Optional[int] = None,
        zip_type: int = 1,
        block_id: typing.Optional[str] = None,
        module_id: typing.Optional[str] = None,
        region: typing.Optional[str] = None,
        uid: typing.Optional[int] = None,
        version: typing.Optional[str] = None,
        page_size: int = 20,
        lang: typing.Optional[str] = None,
    ) -> paginators.PagedPaginator[models.TeapotReplica]:
        """Get a teapot replica paginator."""
        if not region and uid:
            region = utility.recognize_genshin_server(uid)

        return paginators.PagedPaginator(
            functools.partial(
                self._get_teapot_replica_page,
                zip_type=zip_type,
                block_id=block_id,
                module_id=module_id,
                region=region,
                version=version,
                limit=page_size,
                lang=lang,
            ),
            limit=limit,
            page_size=page_size,
        )

Methods

async def request_teapot(self,
endpoint: str,
*,
method: str = 'GET',
lang: str | None = None,
params: Mapping[str, Any] | None = None,
**kwargs: Any) ‑> Mapping[str, Any]
Expand source code
async def request_teapot(
    self,
    endpoint: str,
    *,
    method: str = "GET",
    lang: typing.Optional[str] = None,
    params: typing.Optional[typing.Mapping[str, typing.Any]] = None,
    **kwargs: typing.Any,
) -> typing.Mapping[str, typing.Any]:
    """Make a request towards the teapot endpoint."""
    params = dict(params or {})

    base_url = routes.TEAPOT_URL.get_url(self.region)
    url = base_url / endpoint

    params["lang"] = lang or self.lang

    return await self.request(url, method=method, params=params, **kwargs)

Make a request towards the teapot endpoint.

def teapot_replicas(self,
*,
limit: int | None = None,
zip_type: int = 1,
block_id: str | None = None,
module_id: str | None = None,
region: str | None = None,
uid: int | None = None,
version: str | None = None,
page_size: int = 20,
lang: str | None = None) ‑> PagedPaginator[TeapotReplica]
Expand source code
def teapot_replicas(
    self,
    *,
    limit: typing.Optional[int] = None,
    zip_type: int = 1,
    block_id: typing.Optional[str] = None,
    module_id: typing.Optional[str] = None,
    region: typing.Optional[str] = None,
    uid: typing.Optional[int] = None,
    version: typing.Optional[str] = None,
    page_size: int = 20,
    lang: typing.Optional[str] = None,
) -> paginators.PagedPaginator[models.TeapotReplica]:
    """Get a teapot replica paginator."""
    if not region and uid:
        region = utility.recognize_genshin_server(uid)

    return paginators.PagedPaginator(
        functools.partial(
            self._get_teapot_replica_page,
            zip_type=zip_type,
            block_id=block_id,
            module_id=module_id,
            region=region,
            version=version,
            limit=page_size,
            lang=lang,
        ),
        limit=limit,
        page_size=page_size,
    )

Get a teapot replica paginator.

Inherited members