Skip to content

Commit

Permalink
feat: added new topic "Channel Shared Chat Session End", Teekeks#336
Browse files Browse the repository at this point in the history
  • Loading branch information
Teekeks committed Dec 19, 2024
1 parent efd3fdf commit 7a1ad69
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
5 changes: 4 additions & 1 deletion twitchAPI/eventsub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
24 changes: 23 additions & 1 deletion twitchAPI/eventsub/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
27 changes: 25 additions & 2 deletions twitchAPI/object/eventsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -2601,3 +2619,8 @@ class ChannelSharedChatBeginEvent(TwitchObject):
class ChannelSharedChatUpdateEvent(TwitchObject):
subscription: Subscription
event: ChannelSharedChatUpdateData


class ChannelSharedChatEndEvent(TwitchObject):
subscription: Subscription
event: ChannelSharedChatEndData

0 comments on commit 7a1ad69

Please sign in to comment.