Skip to content

Commit 5225000

Browse files
committed
feat: added new topic "Channel Shared Chat Session Begin"
1 parent e81d6c6 commit 5225000

File tree

3 files changed

+64
-3
lines changed

3 files changed

+64
-3
lines changed

twitchAPI/eventsub/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,9 @@
323323
- Function: :const:`~twitchAPI.eventsub.base.EventSubBase.listen_channel_chat_user_message_update()` |br|
324324
Payload: :const:`~twitchAPI.object.eventsub.ChannelChatUserMessageUpdateEvent`
325325
- A user is notified if their message’s automod status is updated.
326+
* - **Channel Shared Chat Session Begin**
327+
- Function: :const:`~twitchAPI.eventsub.base.EventSubBase.listen_channel_shared_chat_begin()` |br|
328+
Payload: :const:`~twitchAPI.object.eventsub.ChannelSharedChatBeginEvent`
329+
- A notification when a channel becomes active in an active shared chat session.
330+
326331
"""

twitchAPI/eventsub/base.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
ChannelVIPRemoveEvent, ChannelUnbanRequestCreateEvent, ChannelUnbanRequestResolveEvent,
2929
ChannelSuspiciousUserMessageEvent, ChannelSuspiciousUserUpdateEvent, ChannelModerateEvent,
3030
ChannelWarningAcknowledgeEvent, ChannelWarningSendEvent, AutomodMessageHoldEvent, AutomodMessageUpdateEvent,
31-
AutomodSettingsUpdateEvent, AutomodTermsUpdateEvent, ChannelChatUserMessageHoldEvent, ChannelChatUserMessageUpdateEvent)
31+
AutomodSettingsUpdateEvent, AutomodTermsUpdateEvent, ChannelChatUserMessageHoldEvent, ChannelChatUserMessageUpdateEvent,
32+
ChannelSharedChatBeginEvent)
3233
from twitchAPI.helper import remove_none_values
3334
from twitchAPI.type import TwitchAPIException
3435
import asyncio
@@ -1894,3 +1895,25 @@ async def listen_channel_chat_user_message_update(self,
18941895
'user_id': user_id
18951896
}
18961897
return await self._subscribe('channel.chat.user_message_update', '1', param, callback, ChannelChatUserMessageUpdateEvent)
1898+
1899+
async def listen_channel_shared_chat_begin(self,
1900+
broadcaster_user_id: str,
1901+
callback: Callable[[ChannelSharedChatBeginEvent], Awaitable[None]]) -> str:
1902+
"""A notification when a channel becomes active in an active shared chat session.
1903+
1904+
For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channelshared_chatbegin
1905+
1906+
:param broadcaster_user_id: The User ID of the channel to receive shared chat session begin events for.
1907+
:param callback: function for callback
1908+
:raises ~twitchAPI.type.EventSubSubscriptionConflict: if a conflict was found with this subscription
1909+
(e.g. already subscribed to this exact topic)
1910+
:raises ~twitchAPI.type.EventSubSubscriptionTimeout: if :const:`~twitchAPI.eventsub.webhook.EventSubWebhook.wait_for_subscription_confirm`
1911+
is true and the subscription was not fully confirmed in time
1912+
:raises ~twitchAPI.type.EventSubSubscriptionError: if the subscription failed (see error message for details)
1913+
:raises ~twitchAPI.type.TwitchBackendException: if the subscription failed due to a twitch backend error
1914+
:returns: The id of the topic subscription
1915+
"""
1916+
param = {
1917+
'broadcaster_user_id': broadcaster_user_id,
1918+
}
1919+
return await self._subscribe('channel.shared_chat.begin', '1', param, callback, ChannelSharedChatBeginEvent)

twitchAPI/object/eventsub.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
'ChannelVIPAddEvent', 'ChannelVIPRemoveEvent', 'ChannelUnbanRequestCreateEvent', 'ChannelUnbanRequestResolveEvent',
2424
'ChannelSuspiciousUserMessageEvent', 'ChannelSuspiciousUserUpdateEvent', 'ChannelModerateEvent', 'ChannelWarningAcknowledgeEvent',
2525
'ChannelWarningSendEvent', 'AutomodMessageHoldEvent', 'AutomodMessageUpdateEvent', 'AutomodSettingsUpdateEvent',
26-
'AutomodTermsUpdateEvent', 'ChannelChatUserMessageHoldEvent', 'ChannelChatUserMessageUpdateEvent',
26+
'AutomodTermsUpdateEvent', 'ChannelChatUserMessageHoldEvent', 'ChannelChatUserMessageUpdateEvent', 'ChannelSharedChatBeginEvent',
2727
'Subscription', 'ChannelPollBeginData', 'PollChoice', 'BitsVoting', 'ChannelPointsVoting', 'ChannelUpdateData', 'ChannelFollowData',
2828
'ChannelSubscribeData', 'ChannelSubscriptionEndData', 'ChannelSubscriptionGiftData', 'ChannelSubscriptionMessageData',
2929
'SubscriptionMessage', 'Emote', 'ChannelCheerData', 'ChannelRaidData', 'ChannelBanData', 'ChannelUnbanData', 'ChannelModeratorAddData',
@@ -47,7 +47,8 @@
4747
'ModerateMetadataUnvip', 'ModerateMetadataUntimeout', 'ModerateMetadataUnraid', 'ModerateMetadataUnban', 'ModerateMetadataUnbanRequest',
4848
'ModerateMetadataAutomodTerms', 'ModerateMetadataBan', 'ModerateMetadataMod', 'ModerateMetadataVip', 'ModerateMetadataRaid',
4949
'ModerateMetadataFollowers', 'ChannelModerateData', 'ChannelWarningAcknowledgeData', 'ChannelWarningSendData', 'AutomodMessageHoldData',
50-
'AutomodMessageUpdateData', 'AutomodSettingsUpdateData', 'AutomodTermsUpdateData', 'ChannelChatUserMessageHoldData', 'ChannelChatUserMessageUpdateData']
50+
'AutomodMessageUpdateData', 'AutomodSettingsUpdateData', 'AutomodTermsUpdateData', 'ChannelChatUserMessageHoldData', 'ChannelChatUserMessageUpdateData',
51+
'SharedChatParticipant', 'ChannelSharedChatBeginData']
5152

5253

5354
# Event Data
@@ -2228,6 +2229,33 @@ class ChannelChatUserMessageUpdateData(TwitchObject):
22282229
"""The body of the message."""
22292230

22302231

2232+
class SharedChatParticipant(TwitchObject):
2233+
broadcaster_user_id: str
2234+
"""The User ID of the participant channel."""
2235+
broadcaster_user_name: str
2236+
"""The display name of the participant channel."""
2237+
broadcaster_user_login: str
2238+
"""The user login of the participant channel."""
2239+
2240+
2241+
class ChannelSharedChatBeginData(TwitchObject):
2242+
session_id: str
2243+
"""The unique identifier for the shared chat session."""
2244+
broadcaster_user_id: str
2245+
"""The User ID of the channel in the subscription condition which is now active in the shared chat session."""
2246+
broadcaster_user_name: str
2247+
"""The display name of the channel in the subscription condition which is now active in the shared chat session."""
2248+
broadcaster_user_login: str
2249+
"""The user login of the channel in the subscription condition which is now active in the shared chat session."""
2250+
host_broadcaster_user_id: str
2251+
"""The User ID of the host channel."""
2252+
host_broadcaster_user_name: str
2253+
"""The display name of the host channel."""
2254+
host_broadcaster_user_login: str
2255+
"""The user login of the host channel."""
2256+
participants: List[SharedChatParticipant]
2257+
"""The list of participants in the session."""
2258+
22312259
# Events
22322260

22332261
class ChannelPollBeginEvent(TwitchObject):
@@ -2544,3 +2572,8 @@ class ChannelChatUserMessageUpdateEvent(TwitchObject):
25442572
subscription: Subscription
25452573
event: ChannelChatUserMessageUpdateData
25462574

2575+
2576+
class ChannelSharedChatBeginEvent(TwitchObject):
2577+
subscription: Subscription
2578+
event: ChannelSharedChatBeginData
2579+

0 commit comments

Comments
 (0)