Добавлен get_global_emotes

This commit is contained in:
2025-12-11 16:16:30 +03:00
parent 1a0999f332
commit b0d3ca9add
2 changed files with 28 additions and 1 deletions

View File

@ -753,7 +753,7 @@ class TwitchAPIClient(AioHTTPXClient):
cache_time: int | None = None, cache_time: int | None = None,
): ):
req = await self.get( req = await self.get(
'/emotes', '/chat/emotes',
headers=self.clean_dict( headers=self.clean_dict(
{ {
'Authorization': f'Bearer {access_token}', 'Authorization': f'Bearer {access_token}',
@ -772,3 +772,26 @@ class TwitchAPIClient(AioHTTPXClient):
case _: case _:
raise s.Error(req.status_code, 'Internal Server Error') raise s.Error(req.status_code, 'Internal Server Error')
async def get_global_emotes(
self, access_token: str, cache_time: int | None = None
):
req = await self.get(
'/chat/emotes/global',
headers=self.clean_dict(
{
'Authorization': f'Bearer {access_token}',
'X-Cache-TTL': cache_time,
}
),
)
match req.status_code:
case st.OK:
return s.GlobalEmotes.model_validate(req.json())
case st.UNAUTHORIZED:
raise s.Error(req.status_code, req.json()['message'])
case _:
raise s.Error(req.status_code, 'Internal Server Error')

View File

@ -503,3 +503,7 @@ class ChannelEmotes(BaseModel):
data: list[ChannelEmote] data: list[ChannelEmote]
template: str template: str
class GlobalEmotes(ChannelEmotes):
pass