Добавлен get_chat_settings
This commit is contained in:
@ -880,3 +880,36 @@ 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_chat_settings(
|
||||||
|
self,
|
||||||
|
access_token: str,
|
||||||
|
broadcaster_id: int | str,
|
||||||
|
moderator_id: int | str | None = None,
|
||||||
|
cache_time: int | None = None,
|
||||||
|
):
|
||||||
|
req = await self.get(
|
||||||
|
'/chat/settings',
|
||||||
|
headers=self.clean_dict(
|
||||||
|
{
|
||||||
|
'Authorization': f'Bearer {access_token}',
|
||||||
|
'X-Cache-TTL': cache_time,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
params=self.clean_dict(
|
||||||
|
{
|
||||||
|
'broadcaster_id': broadcaster_id,
|
||||||
|
'moderator_id': moderator_id,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
match req.status_code:
|
||||||
|
case st.OK:
|
||||||
|
return s.ChatSettings.model_validate(req.json()).data
|
||||||
|
|
||||||
|
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')
|
||||||
|
|||||||
@ -541,3 +541,25 @@ class ChannelChatBadges(BaseModel):
|
|||||||
|
|
||||||
class GlobalChatBadges(ChannelChatBadges):
|
class GlobalChatBadges(ChannelChatBadges):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ChatSettingsData(BaseModel):
|
||||||
|
model_config = ConfigDict(extra='forbid')
|
||||||
|
|
||||||
|
broadcaster_id: int
|
||||||
|
emote_mode: bool
|
||||||
|
follower_mode: bool
|
||||||
|
follower_mode_duration: int | None
|
||||||
|
moderator_id: int | None = None
|
||||||
|
non_moderator_chat_delay: bool | None = None
|
||||||
|
non_moderator_chat_delay_duration: int | None = None
|
||||||
|
slow_mode: bool
|
||||||
|
slow_mode_wait_time: int | None
|
||||||
|
subscriber_mode: bool
|
||||||
|
unique_chat_mode: bool
|
||||||
|
|
||||||
|
|
||||||
|
class ChatSettings(BaseModel):
|
||||||
|
model_config = ConfigDict(extra='forbid')
|
||||||
|
|
||||||
|
data: list[ChatSettingsData]
|
||||||
|
|||||||
Reference in New Issue
Block a user