From 947f19afbce1a0b32491a2a515c7e8d549724ff9 Mon Sep 17 00:00:00 2001 From: Miwory Date: Thu, 11 Dec 2025 16:13:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=8D=D0=BD=D0=B4=D0=BF=D0=BE=D0=B8=D0=BD=D1=82=20get?= =?UTF-8?q?=5Fchannel=5Femotes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/twitchclient/api.py | 17 +++++++++++++++++ src/twitchclient/schema.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/twitchclient/api.py b/src/twitchclient/api.py index f5f7260..f44e006 100644 --- a/src/twitchclient/api.py +++ b/src/twitchclient/api.py @@ -745,3 +745,20 @@ class TwitchAPIClient(AioHTTPXClient): case _: raise s.Error(req.status_code, 'Internal Server Error') + + async def get_channel_emotes(self, access_token: str, broadcaster_id: int): + req = await self.get( + '/emotes', + headers={'Authorization': f'Bearer {access_token}'}, + params={'broadcaster_id': broadcaster_id}, + ) + + match req.status_code: + case st.OK: + return s.ChannelEmotes.model_validate(req.json()) + + case st.BAD_REQUEST | st.UNAUTHORIZED: + raise s.Error(req.status_code, req.json()['message']) + + case _: + raise s.Error(req.status_code, 'Internal Server Error') diff --git a/src/twitchclient/schema.py b/src/twitchclient/schema.py index e7d4374..1eacdd0 100644 --- a/src/twitchclient/schema.py +++ b/src/twitchclient/schema.py @@ -475,3 +475,31 @@ class Chatters(BaseModel): data: list[ChattersData] pagination: Pagination | dict[Any, Any] | None = None total: int + + +class ChannelEmoteImages(BaseModel): + model_config = ConfigDict(extra='forbid') + + url_1x: str + url_2x: str + url_4x: str + + +class ChannelEmote(BaseModel): + model_config = ConfigDict(extra='forbid') + + id: int + name: str + images: ChannelEmoteImages + tier: int + emote_type: Literal['bitstier', 'follower', 'subscriptions'] + format: list[Literal['animated', 'static']] + scale: list[Literal['1.0', '2.0', '3.0']] + theme_mode: list[Literal['dark', 'light']] + + +class ChannelEmotes(BaseModel): + model_config = ConfigDict(extra='forbid') + + data: list[ChannelEmote] + template: str