Добавлен get_user_emotes

This commit is contained in:
2025-12-11 17:14:35 +03:00
parent a95ddc36d4
commit 9d80ad7d69
2 changed files with 55 additions and 1 deletions

View File

@ -940,3 +940,38 @@ 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_user_emotes(
self,
access_token: str,
user_id: int | str,
after: str | None = None,
broadcaster_id: int | str | None = None,
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,
}
),
params=self.clean_dict(
{
'user_id': user_id,
'after': after,
'broadcaster_id': broadcaster_id,
}
),
)
match req.status_code:
case st.OK:
return s.UserEmotes.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

@ -492,7 +492,22 @@ class ChannelEmote(BaseModel):
name: str name: str
images: ChannelEmoteImages images: ChannelEmoteImages
tier: int tier: int
emote_type: Literal['bitstier', 'follower', 'subscriptions'] emote_type: Literal[
'none',
'bitstier',
'follower',
'subscriptions',
'channelpoints',
'rewards',
'hypetrain',
'prime',
'turbo',
'smilies',
'globals',
'owl2019',
'twofactor',
'limitedtime'
]
format: list[Literal['animated', 'static']] format: list[Literal['animated', 'static']]
scale: list[Literal['1.0', '2.0', '3.0']] scale: list[Literal['1.0', '2.0', '3.0']]
theme_mode: list[Literal['dark', 'light']] theme_mode: list[Literal['dark', 'light']]
@ -585,3 +600,7 @@ class SharedChatSession(BaseModel):
model_config = ConfigDict(extra='forbid') model_config = ConfigDict(extra='forbid')
data: list[SharedChatSessionData] data: list[SharedChatSessionData]
class UserEmotes(ChannelEmotes):
pagination: Pagination | dict[Any, Any] | None = None