diff --git a/twitchAPI/eventsub/__init__.py b/twitchAPI/eventsub/__init__.py index be94831..49dd8c2 100644 --- a/twitchAPI/eventsub/__init__.py +++ b/twitchAPI/eventsub/__init__.py @@ -331,5 +331,8 @@ - Function: :const:`~twitchAPI.eventsub.base.EventSubBase.listen_channel_shared_chat_update()` |br| Payload: :const:`~twitchAPI.object.eventsub.ChannelSharedChatUpdateEvent` - A notification when the active shared chat session the channel is in changes. - + * - **Channel Shared Chat Session End** + - Function: :const:`~twitchAPI.eventsub.base.EventSubBase.listen_channel_shared_chat_end()` |br| + Payload: :const:`~twitchAPI.object.eventsub.ChannelSharedChatEndEvent` + - A notification when a channel leaves a shared chat session or the session ends. """ diff --git a/twitchAPI/eventsub/base.py b/twitchAPI/eventsub/base.py index d56943a..d81a8f9 100644 --- a/twitchAPI/eventsub/base.py +++ b/twitchAPI/eventsub/base.py @@ -29,7 +29,7 @@ ChannelSuspiciousUserMessageEvent, ChannelSuspiciousUserUpdateEvent, ChannelModerateEvent, ChannelWarningAcknowledgeEvent, ChannelWarningSendEvent, AutomodMessageHoldEvent, AutomodMessageUpdateEvent, AutomodSettingsUpdateEvent, AutomodTermsUpdateEvent, ChannelChatUserMessageHoldEvent, ChannelChatUserMessageUpdateEvent, - ChannelSharedChatBeginEvent, ChannelSharedChatUpdateEvent) + ChannelSharedChatBeginEvent, ChannelSharedChatUpdateEvent, ChannelSharedChatEndEvent) from twitchAPI.helper import remove_none_values from twitchAPI.type import TwitchAPIException import asyncio @@ -1939,3 +1939,25 @@ async def listen_channel_shared_chat_update(self, 'broadcaster_user_id': broadcaster_user_id, } return await self._subscribe('channel.shared_chat.update', '1', param, callback, ChannelSharedChatUpdateEvent) + + async def listen_channel_shared_chat_end(self, + broadcaster_user_id: str, + callback: Callable[[ChannelSharedChatEndEvent], Awaitable[None]]) -> str: + """A notification when a channel leaves a shared chat session or the session ends. + + For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channelshared_chatend + + :param broadcaster_user_id: The User ID of the channel to receive shared chat session end events for. + :param callback: function for callback + :raises ~twitchAPI.type.EventSubSubscriptionConflict: if a conflict was found with this subscription + (e.g. already subscribed to this exact topic) + :raises ~twitchAPI.type.EventSubSubscriptionTimeout: if :const:`~twitchAPI.eventsub.webhook.EventSubWebhook.wait_for_subscription_confirm` + is true and the subscription was not fully confirmed in time + :raises ~twitchAPI.type.EventSubSubscriptionError: if the subscription failed (see error message for details) + :raises ~twitchAPI.type.TwitchBackendException: if the subscription failed due to a twitch backend error + :returns: The id of the topic subscription + """ + param = { + 'broadcaster_user_id': broadcaster_user_id, + } + return await self._subscribe('channel.shared_chat.end', '1', param, callback, ChannelSharedChatEndEvent) diff --git a/twitchAPI/object/eventsub.py b/twitchAPI/object/eventsub.py index 124b133..20a6c67 100644 --- a/twitchAPI/object/eventsub.py +++ b/twitchAPI/object/eventsub.py @@ -24,7 +24,7 @@ 'ChannelSuspiciousUserMessageEvent', 'ChannelSuspiciousUserUpdateEvent', 'ChannelModerateEvent', 'ChannelWarningAcknowledgeEvent', 'ChannelWarningSendEvent', 'AutomodMessageHoldEvent', 'AutomodMessageUpdateEvent', 'AutomodSettingsUpdateEvent', 'AutomodTermsUpdateEvent', 'ChannelChatUserMessageHoldEvent', 'ChannelChatUserMessageUpdateEvent', 'ChannelSharedChatBeginEvent', - 'ChannelSharedChatUpdateEvent', + 'ChannelSharedChatUpdateEvent', 'ChannelSharedChatEndEvent', 'Subscription', 'ChannelPollBeginData', 'PollChoice', 'BitsVoting', 'ChannelPointsVoting', 'ChannelUpdateData', 'ChannelFollowData', 'ChannelSubscribeData', 'ChannelSubscriptionEndData', 'ChannelSubscriptionGiftData', 'ChannelSubscriptionMessageData', 'SubscriptionMessage', 'Emote', 'ChannelCheerData', 'ChannelRaidData', 'ChannelBanData', 'ChannelUnbanData', 'ChannelModeratorAddData', @@ -49,7 +49,7 @@ 'ModerateMetadataAutomodTerms', 'ModerateMetadataBan', 'ModerateMetadataMod', 'ModerateMetadataVip', 'ModerateMetadataRaid', 'ModerateMetadataFollowers', 'ChannelModerateData', 'ChannelWarningAcknowledgeData', 'ChannelWarningSendData', 'AutomodMessageHoldData', 'AutomodMessageUpdateData', 'AutomodSettingsUpdateData', 'AutomodTermsUpdateData', 'ChannelChatUserMessageHoldData', 'ChannelChatUserMessageUpdateData', - 'SharedChatParticipant', 'ChannelSharedChatBeginData', 'ChannelSharedChatUpdateData'] + 'SharedChatParticipant', 'ChannelSharedChatBeginData', 'ChannelSharedChatUpdateData', 'ChannelSharedChatEndData'] # Event Data @@ -2276,6 +2276,24 @@ class ChannelSharedChatUpdateData(TwitchObject): participants: List[SharedChatParticipant] """The list of participants in the session.""" + +class ChannelSharedChatEndData(TwitchObject): + session_id: str + """The unique identifier for the shared chat session.""" + broadcaster_user_id: str + """The User ID of the channel in the subscription condition which is no longer active in the shared chat session.""" + broadcaster_user_name: str + """The display name of the channel in the subscription condition which is no longer active in the shared chat session.""" + broadcaster_user_login: str + """The user login of the channel in the subscription condition which is no longer active in the shared chat session.""" + host_broadcaster_user_id: str + """The User ID of the host channel.""" + host_broadcaster_user_name: str + """The display name of the host channel.""" + host_broadcaster_user_login: str + """The user login of the host channel.""" + + # Events class ChannelPollBeginEvent(TwitchObject): @@ -2601,3 +2619,8 @@ class ChannelSharedChatBeginEvent(TwitchObject): class ChannelSharedChatUpdateEvent(TwitchObject): subscription: Subscription event: ChannelSharedChatUpdateData + + +class ChannelSharedChatEndEvent(TwitchObject): + subscription: Subscription + event: ChannelSharedChatEndData