From 76f9914a53c97ae612ca31f8713df37e823b3e1e Mon Sep 17 00:00:00 2001 From: Teekeks Date: Mon, 25 Nov 2024 15:48:15 +0100 Subject: [PATCH] feat: added new endpoint "Get Shared Chat Session", #336 --- twitchAPI/object/api.py | 19 ++++++++++++++++++- twitchAPI/twitch.py | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/twitchAPI/object/api.py b/twitchAPI/object/api.py index 89190af..f01a258 100644 --- a/twitchAPI/object/api.py +++ b/twitchAPI/object/api.py @@ -26,7 +26,7 @@ 'ChannelVIP', 'UserChatColor', 'Chatter', 'GetChattersResponse', 'ShieldModeStatus', 'CharityAmount', 'CharityCampaign', 'CharityCampaignDonation', 'AutoModSettings', 'ChannelFollower', 'ChannelFollowersResult', 'FollowedChannel', 'FollowedChannelsResult', 'ContentClassificationLabel', 'AdSchedule', 'AdSnoozeResponse', 'SendMessageResponse', 'ChannelModerator', 'UserEmotesResponse', - 'WarnResponse'] + 'WarnResponse', 'SharedChatParticipant', 'SharedChatSession'] class TwitchUser(TwitchObject): @@ -859,3 +859,20 @@ class WarnResponse(TwitchObject): reason: str """The reason provided for warning.""" + +class SharedChatParticipant(TwitchObject): + broadcaster_id: str + """The User ID of the participant channel.""" + + +class SharedChatSession(TwitchObject): + session_id: str + """The unique identifier for the shared chat session.""" + host_broadcaster_id: str + """The User ID of the host channel.""" + participants: List[SharedChatParticipant] + """The list of participants in the session.""" + created_at: datetime + """The UTC timestamp when the session was created.""" + updated_at: datetime + """The UTC timestamp when the session was last updated.""" diff --git a/twitchAPI/twitch.py b/twitchAPI/twitch.py index 539909a..be11c38 100644 --- a/twitchAPI/twitch.py +++ b/twitchAPI/twitch.py @@ -4083,3 +4083,22 @@ async def warn_chat_user(self, } return await self._build_result('POST', 'moderation/warnings', param, AuthType.USER, [AuthScope.MODERATOR_MANAGE_WARNINGS], WarnResponse, body_data=data) + + async def get_shared_chat_session(self, broadcaster_id: str) -> Optional[SharedChatSession]: + """Retrieves the active shared chat session for a channel. + + Requires User or App Authentication\n + For detailed documentation, see here: https://dev.twitch.tv/docs/api/reference#get-shared-chat-session + + :param broadcaster_id: The User ID of the channel broadcaster. + :raises ~twitchAPI.type.TwitchAPIException: if the request was malformed + :raises ~twitchAPI.type.UnauthorizedException: if user authentication is not set or invalid + :raises ~twitchAPI.type.TwitchAuthorizationException: if the used authentication token became invalid and a re authentication failed + :raises ~twitchAPI.type.TwitchBackendException: if the Twitch API itself runs into problems + :raises ~twitchAPI.type.TwitchAPIException: if a Query Parameter is missing or invalid + :returns: None if there is no active shared chat session + """ + param = { + 'broadcaster_id': broadcaster_id + } + return await self._build_result('GET', 'shared_chat/session', param, AuthType.EITHER, [], SharedChatSession)