Skip to content

Commit

Permalink
feat: added new endpoint "Get Shared Chat Session", Teekeks#336
Browse files Browse the repository at this point in the history
  • Loading branch information
Teekeks committed Nov 25, 2024
1 parent 2b90657 commit 76f9914
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
19 changes: 18 additions & 1 deletion twitchAPI/object/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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."""
19 changes: 19 additions & 0 deletions twitchAPI/twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 76f9914

Please sign in to comment.